是否有可能检索应用于元素的所有 CSS 规则,即使没有应用(浏览器计算的样式),例如
alert($('#element').css());
应该有这样的功能来显示可以像这样输出的每个 css 规则:
position: static,
height: auto,
width: auto,
font-size: 100%,
line-height: 1,
z-index: 0
// and so on...
最佳答案
这里有一些信息:Get all CSS styles of an element with JavaScript
不幸的是,没有可靠的解决方案,而且看起来会有一些陷阱。 但是,对于简单的调试来说,它应该已经足够好了。
关于jquery - 检索元素的每个 CSS 规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5160870/