radio实现第一次点击选中第二次点击取消

来源:互联网 发布:windows 10如何打开cmd 编辑:程序博客网 时间:2024/05/06 19:57
Jquery代码如下:


$("#add_form .radio input").bind("click",function(){ 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);    }    // remove was checked from other radios    $radio.siblings('input[type="radio"]').data('waschecked', false);});


0 0
原创粉丝点击