CHAPTER 14. JAVASCRIPT AND AJAX 155
14.7 Try It: Change the Class of an Element
If you want to change a whole bunch of styling all at once, one of the easiest
ways is to assign the styling to aclassand then just change the class of the
element.
Here is a JavaScript function we have namedreclassthat usesgetEle-
mentByIdandsetAttributeto change the class of an element. Place it
in your
Here is a style sheet that defines two classes to be used in our example.
Place it in your
Here is some
code to change the class of an item. We click on a