时间:2021-07-01 10:21:17 帮助过:11人阅读
由于项目的需求,要求radio点击两次后为取消状态,不方便修改为checkbox,可以用正面的方法实现。
// jquery
$('input:radio').click(function(){
//alert(this.checked);
//
var $radio = $(this);
// if this was previously checked
if ($radio.data('waschecked') == true){
$radio.prop('checked', false);
$radio.data('waschecked', false);
} else {
$radio.prop('checked', true);
$radio.data('waschecked', true);
}
}); 相关推荐:
jQuery获取单选按钮radio选中值与去除所有radio选中状态实例分享
jQuery实现 RadioButton做必选校验功能方法分享
在html怎样使用radio
以上就是radio第一次点击选中第二次点击取消功能如何实现的详细内容,更多请关注Gxl网其它相关文章!