[英]Why doesn't the following Javascript code (to set CSS style) work?
[英]Javascript set left style doesn't work
xpos=xpos+1;
document.getElementById("img").style.left=xpos;
我无法将xpos值分配给javascript中的left属性。
尝试添加一个单位。 否则,由于CSS无效,浏览器可能无法读取它
document.getElementById("img").style.left= xpos + "px";
通常,您可以通过查看浏览器开发人员工具的样式窗格来弄清此类情况
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.