我怎樣才能確定在選擇框中更改值而無需單擊選擇框本身。Jquery確定選擇框的值是否有變化
我的代碼如下:
JQUERY
$("select").each(function() {
$(this).change(function() {
if ($(this).val() === "-Select-"){
this.parent().addClass("highlightSelect");
this.parent().sibling().show();
} else{
this.parent().removeClass("highlightSelect");
this.parent().sibling().hide();
}
});
});
HTML
<div id="wwctrl_add_savedAddressId" class="wwctrl styled-select">
<select id="add_savedAddressId" class="storedPaymentInput_size4 required savedAddress checkDropdown valid" onchange="changeSavedAddressType();generateSavedAddressAdd();" name="summaryData.usedAddress">
<option value="-Select-">-Select-</option>
<option value="O">Enter New Address</option>
<option value="3041">Home - 116 Parrot...</option>
<option value="22268">Other - rwara, aw...</option>
<option value="21372">Other - 1040..</option>
</select>
</div>
<div class="error" for="add_savedAddressId" generated="true" style="display: none;"> Select item</div>
注:我有這影響了上述選擇框的值的變化,其他按鈕
請提供jsfiddle – Asciiom