Setting Styles with JavaScript

Summary

Summary

Although this article didn't cover everything regarding changing styles, it did cover a lot. We discussed how to write functions, how to pass values to parameter variables, the style attribute, the getElementById method of the document, swapping classes and reading styles.

Setting styles can be achieved with very little code without having to resort to hacks.

There are some differences in the way CSS values are stored in browser memory, as I discussed in the 'Getting CSS values in Netscape' warning. Even with HTML4.0, the DOM, and CSS standards, browser's will still implement things in their own way.

Looking Forward

Multiple Classes

Multiple css classes can be separated by white space. Adding and removing classes from an element's class attribute is a more refined approach that is quite useful. Keep checking the learn section for an upcoming article on multiple classes.

 

*AnimTree
*Tabs
*GlideMenus
*DragLib