正如標題所示,我遇到了綁定到下拉選擇列表中的更改的問題 - 看起來「更改「不適用於IE(7或8),所以當我嘗試替代方法並使用」點擊「事件時,它可以在IE中使用,但在Chrome中無法使用!我在這裏錯過了很明顯的東西嗎jQuery選擇更改/點擊問題 - 更改在IE中不起作用,點擊在Chrome中不起作用
這裏是我的代碼:
//event handler for showing hidden form elements (also ensures only relevant hidden els shown)
//IE needs click event instead of change
$('.select_change').live("change", function(){
//check if value is other
if ($(this).val() == 'other')
$(this).parent().find(".hidden").show();
//if user changes select value from other then hide input
if ($(this).val() != 'other')
$(this).parent().find(".hidden").hide();
return false;
});
下拉HTML如下:
<select id="title" name="title" class="validate[required,funcCall[validateNotDefault]] select_change" >
<option value="default" selected="selected">Please choose from options</option>
<option value="yellow">Yellow</option>
<option value="black">Black</option>
<option value="chocoloate">Chocolate</option>
<option value="other">Other</option>
</select>
感謝尼克 - 作品一種享受 - 並歡呼爲智能化代碼爲了我! – dan727 2010-04-20 21:51:24