JavaScript Reference/Javascript Collections/styleSheets

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

"styleSheets" Example

   <source lang="javascript">
   

<html> <head> <style type="text/css"> .rule1 { font-family:Times New Roman; font-size:18pt; color:blue; } </style> <style type="text/css"> .rule2 { font-family:Verdana; color:red; } </style> </head> <body> <button onclick="function1();">Get total style sheets in this document.</button> <script language="JavaScript">

   function function1() {
       var m = document.styleSheets.length; 
       alert(m);
   }

</script> </body> </html>


     </source>
   
  


"styleSheets" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |document | +----------------+--------------------------------------------------------------+

     </source>
   
  


"styleSheets" JavaScript properties and JavaScript methods

   <source lang="javascript">

JavaScript properties and JavaScript methods

item(), length, namedItem(), urns()


     </source>
   
  


"styleSheets" Syntax Parameters and Note

   <source lang="javascript">

Note: Returns an array of all the style sheets in the <link> and <style> elements.

Syntax:

document.styleSheets // returns all style sheets document.styleSheets(param1, param2) // returns an individual style sheet Parameters:

   param1   Required; zero-based index or
                      the desired member"s id or name attribute.
   param2   Optional; the zero-based index for the result returned 
                      if param1 matches more than one element.
   
     
     </source>