Working with the className Property : HTML CLass Style « HTML « JavaScript DHTML

Working with the className Property

JavaScript Bible, Fourth Edition
by Danny Goodman 

John Wiley & Sons CopyRight 2001

<TITLE>className Property</TITLE>
<STYLE TYPE="text/css">
.special {font-size:16pt; color:red}
function toggleSpecialStyle(elemID) {
    var elem = (document.all) ? document.all(elemID) : document.getElementById(elemID)
    if (elem.className == "") {
        elem.className = "special"
    } else {
        elem.className = ""
<H1>className Property Lab</H1>
<FORM NAME="input">
<INPUT TYPE="button" VALUE="Toggle Class Name" onClick="toggleSpecialStyle('head1')">
<H1 ID="head1">ARTICLE I</H1>

<P>Congress shall make no law respecting an establishment of religion, or
 prohibiting the free exercise thereof; or abridging the freedom of speech, or of
 the press; or the right of the people peaceably to assemble, and to petition the
 government for a redress of grievances.</P>
<P>A well regulated militia, being necessary to the security of a free state,
 the right of the people to keep and bear arms, shall not be infringed.</P>


Related examples in the same category