Get all css styles for a DOM element (a la Firebug)

前端 未结 4 1934
日久生厌
日久生厌 2020-12-19 04:07

For a DOM element, how to I get all styles specified in css for a particular element? Is it a case of iterating over all css style names?

Or is there a more elegant

4条回答
  •  感动是毒
    2020-12-19 04:38

    You should be able to get it with getComputedStyle:

    var css = window.getComputedStyle(element);
    for (var i=0; i
                    
                    0
                  
                       
                    
                   讨论(0)
                  
                                                      
                  
                  
提交回复
热议问题