0
如果圖像的attr值在兩個值之間,我想要採取行動:在我的代碼上,這個.w50
只是寬度attr value = 470pxjQuery - 測試如果img寬度大於'和'小於'
$("img").each(function() {
var image = $(this);
if (image.attr("width") == 470) {
image.parent().addClass('w50');
}
});
我該怎麼寫「如果attr值大於470且小於490,請添加此類」?
它應該是'&&',而不是'||' – Barmar 2015-02-10 01:11:58
@Barmar對不起,當然.. – 2015-02-10 01:13:38
它完美的工作與&&'。謝謝 – BrownBe 2015-02-10 01:15:56