标签: javascript jquery html css
我想在jQuery中的css属性中添加一些存储在我的变量“x”中的像素。
我知道自从jQuery 1.6以来你可以轻松使用这样的东西:
$(this).css({top: "+=150"});
但是当我使用变量而不是150时,它不起作用,因为变量必须用引号写出。
$(this).css({top: "+= x"});
答案 0 :(得分:1)
请试试这个
$(this).css({top: "+= "+ x +"px"});
代替你的代码