JavaScript DHTML/HTML/HTML CLass Style — различия между версиями

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

Версия 10:02, 26 мая 2010

Working with the className Property

/*
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>
<H1>className Property Lab</H1>
<HR>
<FORM NAME="input">
<INPUT TYPE="button" VALUE="Toggle Class Name" onClick="toggleSpecialStyle("head1")">
</FORM>
<BR>
<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>
<H1>ARTICLE II</H1>
<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>
</BODY>
</HTML>