javascript元素.style.left不工作
通过javascript设置元素top,left停止工作,显然它工作得很好javascript元素.style.left不工作,javascript,jquery,html,web,Javascript,Jquery,Html,Web,通过javascript设置元素top,left停止工作,显然它工作得很好 ifrmObj.style.left = 100; ifrmObj.style.top = 150; 现在我必须添加一个带有数字的“px”。我所做的更改是这个问题的原因先使用position,然后使用left或top 语法: object.style.position="static|absolute|fixed|relative|initial|inherit" 对于egs ifrmObj.style.posit
ifrmObj.style.left = 100;
ifrmObj.style.top = 150;
现在我必须添加一个带有数字的“px”。我所做的更改是这个问题的原因先使用position,然后使用left或top 语法:
object.style.position="static|absolute|fixed|relative|initial|inherit"
对于egs
ifrmObj.style.position='absolute';//relative or fixed
要在数字中添加px
对于静态数字
ifrmObj.style.left = '100px';
ifrmObj.style.top = '150px';
变量数
var x=100,y=150;
ifrmObj.style.left = x+'px';
ifrmObj.style.top = y+'px';
如果您使用的是jquery,那么请一次性使用
$(ifrmObj).css({'left':'100px','top':'150px','position':'absolute'});
尝试
ifrmObj.style.left=100+'px'代码>但是没有px它对我有效。以前没有添加px,它对我有效。现在它停止工作了。我们需要找到原因。