0
我有些元素被添加到我的HTML頁面以響應用戶的交互使用jQuery:Internet Explorer的動態添加複選框處理器
addFields = '<div class="individual">
<div class="member">
Name: <input class="firstName" type="text">
<input class="lastName" type="text">
<input class="cit" onChange="citizenInfo(this)" type="checkbox">Non U.S. Citizen?<br/>
</div>
<div class="citInfo" style="display:none">
Country<input class="countryBirth" type="text">
</div>
</div>';
$('#items').append(addFields);
現在我想要的「CIT」複選框切換的知名度'citInfo'div。所以在我的處理複選框我有這個:
function citizenInfo(obj) {
$(obj).parent().parent().find('.citInfo').toggle();
}
這適用於Safari和Firefox,但現在在IE中。如何讓IE切換此div的可見性,以響應點擊複選框?
感謝您的迴應,但我只是試過這個,它甚至在Safari中也不起作用。請注意,這些項目正在動態添加,而不是頁面加載。 – solerous
然後$('input.cit').live('click',function(){// code here} ...這種方式每次添加一個新的複選框,使用實時方法得到該事件處理函數 –
好吧,我真的知道了,我剛剛在我的複選框聲明中將'onChange'更改爲'onClick',並且瞧! – solerous