只是想知道,当使用 jQuery.css()
动态修改页面样式时,跟踪这些更改的位置。这些是否以内联方式应用于元素,或者是否有 jQuery 创建的一些临时 css 文件来跟踪这些更改?
我问的原因是因为我想知道我是否可以访问该数据
最佳答案
引用自 http://api.jquery.com/css/ 的 jQuery 文档:
“When using
.css()
as a setter, jQuery modifies the element's style property. For example,$( "#mydiv" ).css( "color", "green" )
is equivalent todocument.getElementById( "mydiv" ).style.color = "green"
.”
因此,jQuery 不会在任何地方“跟踪”这些更改,而是浏览器本身“跟踪”它们,就像直接通过元素的 style
属性设置任何样式一样。 When the selector matches multiple elements, then jQuery will set the style
for each element individually.
因此,如有必要,可以从那里读回这些样式——再次使用 .css()
,就像只有第一个参数的 getter 一样。
关于jquery - 跟踪 jQuery css 更改的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29290183/