Answers for "jquery add number as id variable"

0

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) );
Posted by: Guest on July-12-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language