JavaScript DHTML/HTML/HTML CLass Style

Материал из Web эксперт
Перейти к: навигация, поиск

Working with the className Property

   <source lang="html4strict">

/* JavaScript Bible, Fourth Edition by Danny Goodman John Wiley & Sons CopyRight 2001

  • /

<HTML> <HEAD> <TITLE>className Property</TITLE> <STYLE TYPE="text/css"> .special {font-size:16pt; color:red} </STYLE> <SCRIPT LANGUAGE="JavaScript"> function toggleSpecialStyle(elemID) {

   var elem = (document.all) ? document.all(elemID) : document.getElementById(elemID)
   if (elem.className == "") {
       elem.className = "special"
   } else {
       elem.className = ""
   }

} </SCRIPT> </HEAD> <BODY>

className Property Lab


<FORM NAME="input"> <INPUT TYPE="button" VALUE="Toggle Class Name" onClick="toggleSpecialStyle("head1")"> </FORM>

ARTICLE I

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.

ARTICLE II

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.

</BODY> </HTML>

      </source>