javascript - How to find the index of a css rule -


i trying find index number of css rule (.widget-area) in stylesheet. how i'm doing it, returns undefined.

function findstyle(){ var mystylesheet=document.stylesheets[8].cssrules[".widget-area"]; console.log(mystylesheet); }; 

if leave out .cssrules[".widget-area"] returns rules of stylesheet, there thousands of them. knows how this?

thanks.

i think using .cssrules function object. if want custom rule should use this:

var targetrule; var rules = document.stylesheets[8].cssrules;  (i=0; i<rules.length; i++){   if (rules[i].selectortext.tolowercase() == ".widget-area"){      targetrule = rules[i];     break;   } } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -