JavaScript Reference/Javascript Properties/selectorText

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

"selectorText" Example

    
<html>
<body>
<style>
#myP { font-family:verdana, arial; }
</style>
<script language="JavaScript">
    function function1() {
        alert(document.styleSheets[0].rules[0].selectorText);
    }
</script>
<p id="myP" onclick="function1()">Sample text.</p>
<input type="button" value="Selector Text" onclick="function1()">
</body>
</html>



"selectorText" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |page                            rule                          |
+----------------+--------------------------------------------------------------+



"selectorText" Syntax and Note

Note:
Read and write property. 
Specifies the selector of the style sheet rule. 
The selector is either the element id or the element tag name.
    
Syntax:
    
document.styleSheets[index1].rules[index2].selectorText = value