JavaScript Reference/Javascript Objects/rule
Содержание
"rule" Example
<source lang="javascript">
<html> <head> <style>
- myP { font-family:verdana, arial; font-weight:bold; font-size:16px; }
</style> <script language="JavaScript"> function function1() {
var myRule = document.styleSheets(0).rules(0); var n = myRule.selectorText; alert(n);
} </script> </head> <body>
This is the text with a specific style rule applied.
<input type="button"
value="Click here to view the styleSheet selector" onclick="function1();">
</body> </html>
</source>
"rule" is applied to
<source lang="javascript">
Names noted with an asterisk (*) are JavaScript properties only. +----------------+--------------------------------------------------------------+ | Applied_To |rules* | +----------------+--------------------------------------------------------------+
</source>
"rule" JavaScript Objects
<source lang="javascript">
+----------------+--------------------------------------------------------------+ | JavaScript |style | +----------------+--------------------------------------------------------------+
</source>
"rule" JavaScript Properties
<source lang="javascript">
+----------------+--------------------------------------------------------------+ | JavaScript |readOnly selectorText | +----------------+--------------------------------------------------------------+
</source>
"rule" Syntax and Note
<source lang="javascript">
Note: Affect a specific rule in a style sheet. You can only access the rule object by referencing the desired index in the rules collection.
Syntax:
document.styleSheets(index1).rules(index2).memberName
</source>