I wanted to change a CSS value using JavaScript…
…but it did not work in browsers other than Firefox. I looked at my code, it seemed to be okey. I couldn’t use Firebug, since the script worked in Firefox.
After a bit longer looking at my code I found the problem. I used a semicolon inside the string for the CSS. It looked a bit like this: elm.style.display = "none;";. After deleting the semicolon it all worked as intended. A bit weird you cannot use it in this kind of statements, but can when you use the cssText property. And also since you must use it in CSS too.
I made a page in my codex that illustrates the problem. In Firefox it works like expected. IE6 and IE7 both do absolutely nothing useful (they give errors) and other browsers make the text white, but the background not black.
Posted on Monday, September 3rd, 2007 in JavaScript
Comments and trackbacks are welcome.
