admin管理员组文章数量:1426072
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.
本文标签: javascriptwhat the meaning of plus operator in this JQUERY scriptsStack Overflow
版权声明:本文标题:javascript - what the meaning of plus operator in this JQUERY scripts - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745464331a2659466.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论