I want to ask mean of plus operator in this script +i+ in the follow:
i=0;
// next line in scripts write this code :
$('.container[data-id='+i+']').hide(); // +i+ what the meaning of it
Need Help thanks a TON
I want to ask mean of plus operator in this script +i+ in the follow:
i=0;
// next line in scripts write this code :
$('.container[data-id='+i+']').hide(); // +i+ what the meaning of it
Need Help thanks a TON
Share Improve this question asked Dec 13, 2010 at 7:57 Joko WandiroJoko Wandiro 1,9872 gold badges18 silver badges29 bronze badges 3- is the above code written by you or its there like that?? – kobe Commented Dec 13, 2010 at 8:03
- while giving dynamic values in between strings we use somethinglike var finalval= dynamic1 + "test" + dynamic2 – kobe Commented Dec 13, 2010 at 8:04
- @another programmer write like this and it works, it reference to variable like in the for loop statement – Joko Wandiro Commented Dec 13, 2010 at 8:05
4 Answers
Reset to default 4+
is used to concatenate strings
In this case, it is used to concatenate the value of i
between .container[data-id= and ]
Assuming that i is storing some value eg 0, then this will be evaluated to
$('.container[data-id=0]').hide();
This will concatenate the value in the variable i
with the remaining string.
See Concatenating strings
+ is used for string concantination
var test= "hello" + "world";// gives helloworld
it is used for adding values also
var c= a+ b// if a=10 and b=20 it gives 30
The +
operator in JavaScript is used for both Arithmetic and String operations.
If both operands are of Number
type, the result is the sum. If either of the operands is not a number, then both will be converted to String
and concatenated. It should be used with care.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745464332a4628850.html
评论列表(0条)