rules Ä÷º¼ÇÀ¸·ÎºÎÅÍ ÇÑ °³Ã¼¸¦ ¹ÝȯÇÑ´Ù.
¹Ýȯ°ª oRuleÀº ¼º°øÀûÀ̸é rule °³Ã¼¸¦ ¹ÝȯÇÏ°í, ½ÇÆÐÇϸé nullÀ» ¹ÝȯÇÑ´Ù.
°³Ã¼ | script | IE |
---|
¹®ÀÇ id°¡ sampleCssÀÎ styleSheets·ÎºÎÅÍ item ¸Þ¼µå·Î °³º° Ç׸ñÀ» ¹Ýȯ¹Þ¾Æ ±× ¸í·É(rule)µéÀ» µð½ºÇ÷¹ÀÌÇÑ´Ù.
<LINK id="sampleCss" rel="stylesheet" type="text/css" href="../object/exp/styleSheetTest.css"> <LINK id="sample1Css" rel="stylesheet" type="text/css" href="../object/exp/sample.css"> <SCRIPT> function showStyleSheets(){ cssObj=document.styleSheets.item('sampleCss'); var oColl=cssObj.rules; str='cssObj.rules.length='+oColl.length+'<BR>'; if (oColl!=null){ for (i=0;i< oColl.length;i++){ str+=i+'] oColl.item('+i+').selectorText=<FONT color=blue>'+oColl.item(i).selectorText+'</FONT><BR>'; str+=i+'] oColl.item('+i+').style.cssText=<FONT color=green>'+oColl.item(i).style.cssText+'</FONT><BR>'; } } showA.innerHTML=str; } function showSelectorText(){ cssObj=document.styleSheets.item('sample1Css'); str='cssObj.rules.length='+cssObj.rules.length+'<BR>'; if (cssObj.rules!=null){ for (i=0;i< cssObj.rules.length;i++){ str+=i+'] cssObj.rules.item('+i+').selectorText=<FONT color=blue>'+cssObj.rules.item(i).selectorText+'</FONT><BR>'; } } showA.innerHTML=str; } </SCRIPT> <DIV class=stylesheetTestClass>1¹ø ½ºÅ¸ÀϽ¬Æ®¸¦ Àû¿ëÇÑ DIV</DIV> <BUTTON onclick="showStyleSheets()">½ºÅ¸ÀϽ¬Æ® Ç׸ñ º¸±â 1</BUTTON> <BUTTON onclick="showSelectorText()">½ºÅ¸ÀϽ¬Æ® Ç׸ñ º¸±â 2</BUTTON> <DIV id=showA>°á°ú Ç¥½Ãâ</DIV>