【发布时间】:2021-03-03 23:58:45
【问题描述】:
我有一个代码,我在其中迭代元素,我想获得每个元素的 css 样式。 我得到这个错误指的是.each:
Uncaught TypeError: Cannot read property 'replace' of undefined
示例代码如下:
$("span").each(function(i,v){
test($(this));
})
function test(element){
console.log(element.css()); //not working
console.log($(element).css()); //not working either
}
【问题讨论】:
-
我做到了。当我不知道所有可能的规则时,我只想获得所有样式