Reading non-inline CSS style info from Javascript

前端 未结 4 1090
栀梦
栀梦 2020-12-03 09:16

I know I must be missing something here, but I cannot seem to get this to work.

I have assigned a background color to the body of an html document using the style ta

4条回答
  •  一整个雨季
    2020-12-03 10:06

    Here is a function you can use (without the use of a framework ie) that was posted here by InsDel:

    function getStyle(className) {
        var classes = document.styleSheets[0].rules || document.styleSheets[0].cssRules
        for(var x=0;x

提交回复
热议问题