Hey friends,
In a few days ago, I’ve just stuck with how to change “float” style in JavaScript and very confuse why it doesn’t work at all!
I’m using …
var obj = document.getElementById(“some1”);
obj.style.float = “left”;
No luck at all. I tried both on Internet Explorer and Firefox. Even I use Internet Explorer Toolbar and Firebug. I can change the style via that tools but no luck with JavaScript.
Silly?
I’m fool with DOM. I try to find a solution and suddenly found that.
In DOM, there are no “float” property but “cssFloat”.
Just change my code to …
var obj = document.getElementById(“some1”);
obj.style.cssFloat = “left”;
Really silly huh?
Never mind. It’s working now.
Ohh, by the way, I forgot to mention:
domObject.cssFloat = value; // This will only work on FireFox, will not work in IE.
domObject.styleFloat= value; // This will work on IE but it will not work on FireFox.
lol
Just ensure using both properties together, and that’s it.
Cordially,
Agustin,
RSS feed for comments on this post · TrackBack URI
Agustin said,
August 20, 2008 @ 2:44 amYour “silly” post (as you called it) helped me out.
I noticed, after a few minutes, “float” alone seemed to be a reserved word, then I remembered the float property should be called with a different name when invoked from javascript.
domObject.cssFloat = value; // That’s the way.
Thanks for your helpful post !
Cordially,
Agustin Garzon