This question already has answers here:
How can I do string interpolation in JavaScript?
(21 answers)
Closed 6 years ago.
I have the following code
dt.ajax.url( 'test.php?status=' ).load();
I defined a variable
var status= 55
I wand to add status_2 in the link like this
dt.ajax.url( 'test.php?status=&status' ).load();
How can I do it ?
Try this. You need to concatenate the variable with url
dt.ajax.url('test.php?status='+status).load();
Related
This question already has answers here:
How do I put a variable in a string using javascript
(4 answers)
jQuery passing element ID into jquery statement?
(6 answers)
How to interpolate variables in strings in JavaScript, without concatenation?
(17 answers)
Closed 4 years ago.
I'm trying to select a specific audio element based on the key that's pressed. The issue is the compiler is reading the variable as a string. How can I get it to read it as a variable?
var hail = e.keyCode
var afile = document.querySelector("audio[data-id='hail']")
You can use Javascript template strings :
var hail = e.keyCode
var afile = document.querySelector(`audio[data-id=${hail}]`)
This question already has answers here:
What does this symbol mean in JavaScript?
(1 answer)
What does curly brackets in the `var { ... } = ...` statements do?
(4 answers)
What do {curly braces} around javascript variable name mean [duplicate]
(1 answer)
Closed 4 years ago.
I was reading some JavaScript code and saw a line of code similar to this.
const {name, password, email} = user;
I tried searching around but could not figure out what this syntax is called so I am not able find the documentation. Is this a new JavaScript syntax? What is it called? What does it do exactly?
This question already has answers here:
What does (function($) {})(jQuery); mean?
(6 answers)
What is the (function() { } )() construct in JavaScript?
(28 answers)
Closed 5 years ago.
I see in the jQuery code this structure but I don't know the name and how use correctly.
(function($) {
...
})(jQuery);
I suppose it's a form of past arguments to the function.
this will execute the function immediately (immediately invoked)
This question already has answers here:
Add a property to a JavaScript object using a variable as the name? [duplicate]
(14 answers)
Closed 7 years ago.
I have the following code where MODE is a variable. Its value should be a method of jQuery's tinycolor liberary.
$cor = tinycolor($cor).mode(z).toString();
I'd like to call that method on that line so, for instance, when mode = 'lighten' $cor would be
$cor = tinycolor($cor).lighten(z).toString();
Is there a way of doing it this way?
Thanks!
Use bracket notation
$cor = tinycolor($cor)[mode](z).toString();
This question already has answers here:
What is the difference between client-side and server-side programming?
(3 answers)
Closed 8 years ago.
I would like to know how to make use of the variable hash in a PHP variable
var hash = md5(a);
Here is the equivalent in PHP:
$hash = md5($a);