标签: jquery var
我应该怎么说:
var numRand = Math.floor(Math.random()*10001) $('.background').css({backgroundPosition: "0 (numRand)px"});
谢谢!
答案 0 :(得分:2)
由于numRand是变量,您需要使用+连接它:
numRand
+
$('.background').css({backgroundPosition: "0 " + numRand + "px"});