JavaScript Reference/Javascript Properties/className

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

"className" Example

   <source lang="javascript">
   

<html> <head> <script language="JavaScript">

   function function1() {
       document.getElementById("myP").className = "myC"
   }

</script> <style> .myC {

   font-family:verdana, arial; 
   font-weight:bold; 
   font-size:16px; 

} </style> </head> <body>

Render this text using the myC class

</body> </html>


     </source>
   
  


"className" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <acronym> | | |<address> <applet> | | |<area> | | |<base> <basefont> | | | |

| |
<body> |

| |
<button> |

| |
|

| | | | |<col> <colgroup> | | |<custom>

| | | |

| |<dir>
| | |
| | | <embed> | | |<fieldset> | | |<form> <frame> | | |<frameset> <head> | | |<hn>
|

| |<html> | | |<iframe> <img> | | |<input type="button"> <input type="checkbox"> | | |<input type="file"> <input type="hidden"> | | |<input type="image"> <input type="password"> | | |<input type="radio"> <input type="reset"> | | |<input type="submit"> <input type="text"> | | | <isindex> | | | <label> |

| |<legend>
  • | | |<link> <listing> | | |<map> <marquee> | | |<menu> <meta> | | |<nobr> <noframes> | | |<noscript> <object> | | |
      <optgroup> | | |<option>

      | | |<param>

                               |
      |                |                                                       |
      |                |                                                     |
      |                |                          <script>                      |
      |                |<select>                                               |
      |                |                                                |
      |                |                        <style>                       |
      |                |                                                    |
      |                |                         <tbody>                       |
      |                |                          |
      |                |                             
        | | | <xmp> | +----------------+--------------------------------------------------------------+ </source>

        "className" Syntax and Note

        <source lang="javascript"> Note: Read and write property. Sets the CSS class or selector applied to the element.

        Syntax:

        document.getElementById("elementID").className = value document.all.elementID.className = value // IE only


        </source>

      <textarea> | | |<tfoot> |

      | |<thead> <title> |

      | |