📜  jquery 添加数字作为 id 变量 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:49.727000             🧑  作者: Mango

代码示例1
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) );