Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery add number as id variable

You need to add parenthesis () for priority to evaluate add loopVar first. If your variable contains numeric value then do not need to apply parseInt function.

loopVar = "1";
alert('#imgAvatar'+(parseInt(loopVar)+1));

OR

loopVar = 1;
alert('#imgAvatar'+ (loopVar+1) );
 
PREVIOUS NEXT
Tagged: #jquery #add #number #id #variable
ADD COMMENT
Topic
Name
7+8 =