我正在尝试根据 css 属性进行选择(在我的情况下top
)。
HTML:
<i style="top:1px;">1px</i><br/>
JS:
$('i').each(function() {
var top = $(this).css('top');
console.log('top = '+top);
if(top == '1px') j(this).css('border','1px solid green');
});
但这不起作用。顶部的值为“自动”。小提琴:http: //jsfiddle.net/forgetcolor/qUjWq/
我猜这与计算样式(?)有关,但不确定。这是怎么回事,有没有办法根据风格区分标签?(在我的应用程序中,我无法控制编写的 HTML,因此无法更改它)。