How to get CSS class by name from StyleSheet?

后端 未结 3 1791
忘掉有多难
忘掉有多难 2021-01-15 22:39

I have the following code which uses the index to get stylesheet and also css class inside that stylesheet.

 for (var s = document.styleSheets.length - 1; s         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-15 23:18

    var someVar = document.querySelectorAll('.someClass');
    for(var i=0; i

    This will grab all of the elements with the class 'someClass' and change the background color.

提交回复
热议问题