Usually it's done:
Code:
elem.style.left = xval + 'px';
And it should be fine with the parentheses. And yes it works in IE. So the problem is likely that in IE elem and/or xval are not as you expect them to be in at that point in the code.
Like xval could be NaN, or elem could be 'null or not an object', or qualify for 'object has no such object or property'. Or something else. Perhaps the event that sets this all in motion hasn't been assigned in IE . . .
For instance, this works fine in IE and others:
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
var xval = 100;
function moveit(el){
el.style.position = 'relative';
el.style.left = xval + 'px';
}
</script>
</head>
<body>
<div style="background-color:blue;width:20px;height:20px;" onclick="moveit(this);"></div>
</body>
</html>
Are you getting any errors in the IE developer tools script console?
To diagnose this further it would be a great help to have a link to a page that demonstrates the problem.
Bookmarks