element.style.left returns NaN

Two ways to fix it.

1. put the inline css style within the html element
<div style="left:280px;">bla</div>


or


2. use the function below
function getStyle(el,styleProp)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}



http://www.quirksmode.org/dom/getstyles.html

你可能感兴趣的:(element)