To change a CSS value in JavaScript, you would access the style object, converting the intended CSS property to “camel case”. For example, the CSS property “margin-left” becomes marginLeft; the property background-color becomes backgroundColor, and so on. But with the float property, it’s different, because float is already a reserved word in JavaScript. So, the following would be incorrect:
myDiv.style.float = “left”;
Instead, you would use one of the following:
// For Internet Explorer
myDiv.style.styleFloat = “left”;
// For all other browsers
myDiv.style.cssFloat = “left”;
No comments:
Post a Comment