DOM Enlightenment by Cody Lindley

DOM Enlightenment by Cody Lindley

Author:Cody Lindley
Language: eng
Format: epub, pdf
Tags: COMPUTERS / Programming Languages / JavaScript
ISBN: 9781449342838
Publisher: O’Reilly Media
Published: 2013-02-11T16:00:00+00:00


6.5 Using the class and id Attributes to Apply and Remove CSS Properties on an Element

Style rules defined in an inline stylesheet or an external stylesheet can be added or removed from an element by using the class and id attributes. This is the most common pattern for manipulating element styles. In the following code, leveraging setAttribute() and classList.add(), inline style rules are applied to a <div> by setting the class and id attribute values. Using removeAttribute() and classList.remove(), these CSS rules can be removed as well.

Live code



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.