views:

696

answers:

2

For some reason I'm unable to set the "top" and "left" CSS attributes using the following JavaScript.

var div = document.createElement('div');
div.style.position = 'absolute';
div.style.top = 200;
div.style.left = 200;
document.body.appendChild(div);

Using Firebug I can see that the div gets the position set to "absolute" but the top and left attributes are not set!

This is for Firefox 3.6.

+4  A: 
div.style.top = "200px";
div.style.left = "200px";

?

Lyubomyr Shaydariv
Damn... :| Thanks.
Deniz Dogan
A: 

yes this code is working ..I had a same problem