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

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

由于项目的需求,要求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);    }  });

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!

tag:取消功能电脑软件jqueryradio

相关内容