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

前端 未结 4 1921
日久生厌
日久生厌 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条回答
  •  萌比男神i
    2020-12-19 04:53

    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?

    Yes, it is.

    Or is there a more elegant way?

    I don't know about more elegant (elegance is pretty high on the subjective scale), but it would certainly be shorter and sweeter if you made use of a library such as jQuery, here's a solution someone coded to answer another question:

    How Can I Get List Of All Element CSS Attributes with jQuery?

    How does Firebug do it?

    I have no idea.

提交回复
热议问题