More specifically, why do I need the + sign on both sides of my variable ? Here there is an example , for more context of what I'm asking: link
Asked
Active
Viewed 49 times
-4
-
2documentation [here](https://api.jquery.com/nth-child-selector/) read about it – guradio Jul 12 '16 at 09:03
-
`why do I need the + sign on both sides of my variable?` because you're concatenating a string. – Rory McCrossan Jul 12 '16 at 09:10
2 Answers
0
You're effectively defining a CSS selector, see docs.
The selector must be a string, $n
here is a variable and the +
signs concatenate (join together) the string and the variable.

robstarbuck
- 6,893
- 2
- 41
- 40
0
+
operator use for concat
two string in javascript
and jQuery
Example:
var a = 'Avanish';
var b = a+' Kumar';
console.log('Value of a---->'+a);
console.log('Value of b---->'+b);
output is
Value of a---->Avanish
Value of b---->Avanish Kumar
http://www.w3schools.com/js/js_operators.asp
How to force addition instead of concatenation in javascript