15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

12 <strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

elementObject.className<br />

Listing 15-5: Working with the className Property<br />

<br />

<br />

className Property<br />

<br />

.special {font-size:16pt; color:red}<br />

<br />

<br />

function toggleSpecialStyle(elemID) {<br />

var elem = (document.all) ? document.all(elemID) :<br />

document.getElementById(elemID)<br />

if (elem.className == “”) {<br />

elem.className = “special”<br />

} else {<br />

elem.className = “”<br />

}<br />

}<br />

<br />

<br />

<br />

className Property Lab<br />

<br />

<br />

<br />

<br />

<br />

ARTICLE I<br />

Congress shall make no law respecting an establishment of religion, or<br />

prohibiting the free exercise thereof; or abridging the freedom of speech, or of<br />

the press; or the right of the people peaceably to assemble, and to petition the<br />

government for a redress of grievances.<br />

ARTICLE II<br />

A well regulated militia, being necessary to the security of a free state,<br />

the right of the people to keep and bear arms, shall not be infringed.<br />

<br />

<br />

You can also create multiple versions of a style rule with different class selector<br />

identifiers and apply them at will to a given element.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!