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.
精彩评论