2012-01-26 40 views

回答

0
function getDefinedCss(s){ 
    if(!document.styleSheets) return ''; 
    if(typeof s== 'string') s= RegExp('\\b'+s+'\\b','i'); // IE capitalizes html selectors 

    var A, S, DS= document.styleSheets, n= DS.length, SA= []; 
    while(n){ 
     S= DS[--n]; 
     A= (S.rules)? S.rules: S.cssRules; 
     for(var i= 0, L= A.length; i<L; i++){ 
       tem= A[i].selectorText? [A[i].selectorText, A[i].style.cssText]: [A[i]+'']; 
       if(s.test(tem[0])) SA[SA.length]= tem; 
     } 
    } 
    return SA.join('\n\n'); 
} 

// Then you check the class if exists by calling getDefinedCss('myclassname') 
+2

這是什麼? –

+0

我也很好奇:)。 – cxw

+0

我真的不知道:)這似乎是一個JS函數來檢查一個CSS類是否存在。不知道現在是否有效,但是因爲它在2012年標記爲正確答案,所以它應該在那個時間工作:D – Ashraf

0

可以使用CSSLint引擎在應用程序中。其來源可在https://github.com/stubbornella/csslint

+0

我去了js鏈接網站並輸入:

  • 11. Validate ValidationGroup
  • 12. jquery validate
  • 13. jquery validate()問題
  • 14. std :: error_code,my_error :: check_block == my_error :: validate && my_error :: accept_block == my_error :: validate
  • 15. solr schema.xml validate
  • 16. Dropwizard Validate @FormParam
  • 17. codeigniter unix timestamp validate
  • 18. Jquery .validate require_from_group
  • 19. Jquery validate onValid
  • 20. xml validate value null
  • 21. Spring boot validate form
  • 22. Validate vs ValidateAsync
  • 23. Hibernate - hibernate.hbm2ddl.auto = validate
  • 24. java swing validate textfield
  • 25. Jquery Validation validate form-array
  • 26. asp.net mvc validate [HttpPost] ActionResult()
  • 27. VueJS 2和Vee-Validate
  • 28. jQuery .validate()submitHandler不叫
  • 29. Jquery validate showerrors display name
  • 30. Java VolatileImage - validate()vs contentsLost()