我想要这个功能:如何在双击时取消选中单选按钮?
当用户点击已经选中的单选按钮时,它应该取消选中它。
我正在尝试此代码,但没有运气。
$(document).on('mouseup','className',function(){
if ($(this).is(':checked')){
$(this).prop('checked', false);
}
});
我想要这个功能:如何在双击时取消选中单选按钮?
当用户点击已经选中的单选按钮时,它应该取消选中它。
我正在尝试此代码,但没有运气。
$(document).on('mouseup','className',function(){
if ($(this).is(':checked')){
$(this).prop('checked', false);
}
});
您可以尝试
$(document).on('dblclick','.className',function(){
if(this.checked){
$(this).prop('checked', false);
}
});
演示:Fiddle
您可以使用.dblclick():
$(document).on('dblclick','className',function(){
if ($(this).is(':checked')){
$(this).prop('checked', false);
}
});
我想是这样的:
$(document).on('dblclick','.yourCls',function(){
if(this.checked){ // if true
$(this).prop('checked', !this.checked); // then !this.checked == false
}
});
那么你必须检查它的选中状态this.checked
返回布尔值true/false
。如果true
取消选中它或检查它。
尝试这个
HTML
<input type="radio" class="rdCheck" checked="checked" text="click me"/> click me
JS
$('.rdCheck').dblclick(function(){
if($(this).is(':checked'))
{
$(this).removeAttr('checked');
}
});
复制? http://stackoverflow.com/questions/2117538/jquery-how-to-uncheck-a-radio-button – Eddie