开发者

when to use elem.style.left o r elem.offsetLeft

When you are trying to get the left valu开发者_Python百科e of an element, what is the difference between elem.style.left or elem.offsetLeft in javascript?


the difference is that elem.offsetLeft is a computed value of left offset, calculated by browser even if you haven't specified explictly the same property via style and/or CSS, instead elem.style.left it's a get of property left of style attribute

try this code: http://jsfiddle.net/nnryG/

the computedValue is unitless, the style property is what you assigned in inline style.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜