我使用下面的代碼:單選按鈕被選中,儘管檢查屬性被刪除
$('#send_order_form input[type="radio":checked]').each(function(){ this.checked = false; });
但我還是看到了單選按鈕點擊。在檢查元素時,檢查的屬性實際上被刪除。 Wierd,我正在使用chrome。
我使用下面的代碼:單選按鈕被選中,儘管檢查屬性被刪除
$('#send_order_form input[type="radio":checked]').each(function(){ this.checked = false; });
但我還是看到了單選按鈕點擊。在檢查元素時,檢查的屬性實際上被刪除。 Wierd,我正在使用chrome。
嘗試使用jQuery removeAttr,而不是刪除選中的屬性:
$('#send_order_form input[type="radio":checked]').each(function(){ $(this).removeAttr("checked"); });
試試這個:
$('#send_order_form input[type="radio":checked]').each(function(){
$(this).prop('checked', false);
});
已經嘗試過了,沒有效果。 –
嘗試將'false'參數更改爲空字符串''''。 –
哦,我正在使用錯誤的參數。看到我更新的答案 - 使用'prop()',而不是'attr()'。 –
你在你選擇的檢查輸入有微小誤差。試試這個:
$('#send_order_form input[type="radio"]:checked').each(function(){
this.checked = false;
});
甚至
$('#send_order_form input[type="radio"]:checked').attr('checked', false);
我使用的是表單中的形式更好。這就是問題出現的原因。現在刪除子窗體後,問題就解決了。
沒有變化,我仍然看到按鈕被點擊。我再說一遍,在檢查元素時,檢查屬性實際上被刪除。 –
@SamarRizvi請看看這個http://jsfiddle.net/CdLwg/1/ –