jQuery - How to get all styles/css (defined within internal/external document) with HTML of an element

前端 未结 9 2012
不知归路
不知归路 2020-12-01 08:22

I know that $(\"#divId\").html() will give me innerHtml. I also need its styles (which might be defined by the means of classes) either in-line style

9条回答
  •  醉酒成梦
    2020-12-01 08:50

    Based on kirilloid's answer, I've created a developer tools extension for Chrome that incorporates that code for capturing styles and markup for a page fragment. The extension is in the Chrome Web Store and is on Github. All of the "Author Styles" output options use that method for iterating over the stylesheets.

    enter image description here

提交回复
热议问题