0
点赞
收藏
分享

微信扫一扫

单选按钮选中、取消

辰鑫chenxin 2022-05-27 阅读 171

<input type="radio" name="xxx">
$(function() {
$(‘input:radio’).click(function () {

  1. ​ //alert(this.checked);​

  2. ​ var domName = $(this).attr('name');​

  3. ​ var $radio = $(this);​
  4. ​ // if this was previously checked​
  5. ​ if ($radio.data('waschecked') == true) {​
  6. ​ console.log($radio.data('waschecked') == true);​
  7. ​ $radio.prop('checked', false);​
  8. ​ //$("input:radio[name='radio" + domName + "']").data('waschecked',false);​
  9. ​ $radio.data('waschecked', false);​
  10. ​ } else {​
  11. ​ console.log($radio.data('waschecked') == true);​
  12. ​ $radio.prop('checked', true);​
  13. ​ //$("input:radio[name='radio" + domName + "']").data('waschecked',true);​
  14. ​ $radio.data('waschecked', true);​
  15. ​ }​
  16. ​ });​
  17. ​});​

举报

相关推荐

0 条评论