<div class="price-holder">
<div class="multiple-price">
<div class="sale">Sale $179.99 </div>
<div class="original">Regular $199.99 </div>
</div>
<div class="swatch-container-new">
<div class="swatch active" ><a href="#" title="Blue" rel="1107910_Blue.jpeg" class="swatch-color color20"></a></div>
<div class="swatch" ><a id="colorId" href="#" title="Purple" rel="1107910_Purple.jpg" class="swatch-color color1"></a></div>
<div class="swatch" ><a id="colorId" href="#" title="Turquoise" rel="1107910_Turquoise.jpeg" class="swatch-color color17"></a></div>
<div class="swatch" ><a id="colorId" href="#" title="Green" rel="1107910_Green.jpg" class="swatch-color color22"></a></div>
<div class="swatch" ><a id="colorId" href="#" title="Pink" rel="1107910_Hot_Pink.jpeg" class="swatch-color color14"></a></div>
</div>
</div>
我的jQuery部分:
var colorBoolean=$("a #colorId:not(:empty)");
alert(colorBoolean);
当我在jQuery中执行此操作时,它正在警告为[object Object]。如何检查sizeBoolean是真还是假?
答案 0 :(得分:0)
将其设为布尔值
var colorBoolean = $("a #colorId:not(:empty)").length > 0
目前你只是返回一个jQuery对象,检查它是否存在,检查length