我在我的選擇選項腳本中有一些問題,但我不明白,什麼是錯的?對不起,我不是真正的jQuery專家。做一些選擇開關
HTML
<fieldset>
<select id="sorting">
<option value="1">A-Z</option>
<option value="2">Number</option>
</select>
</fieldset>
jQuery的
$(document).change(function() {
if($("#sorting").prop("selectedIndex", 1)) {
alert("A-Z");
}
else if($("#sorting").prop("selectedIndex", 2)) {
alert("Number");
}
});
我的問題:它總是 「AZ」,我不能切換到 「數字」 選擇號碼;(
這裏是我的fiddle
非常簡單 - > https://jsfiddle.net/bymfjrfk/1/ – adeneo