Posted by
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?
Under IE6 you must use this:
obj.style.styleFloat=’left’;
Ohh thx!
i figured that it needed something in front, since float really is a datatype, so using it in obj.style.float would be impossible.