Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 jQuery 的菜鸟,我尝试了以下代码但不起作用。谁能告诉我如何使用jQuery将leftValue分配给“left”作为以下代码?
var i =0; var leftValue = seat_xcoord*20; $('#seat'+i).css({left: $leftValue});
干杯。
尝试这个
$('#seat'+i).css({left: leftValue + 'px'});
你有$leftValue 而不是leftValue
并确保有元素id="seat0"
id="seat0"
检查演示
从您的 leftValue 变量中删除 $ 并连接像素单位的“px”。