单选按钮点击取消 、选中

<input name="radio1" value="cg" type="radio" tag="0" />唱歌
<br />
<input name="radio2" value="yr" type="radio" tag="0" />游泳
 <br />
 <input name="radio3" value="pb" type="radio" tag="0" />跑步
$(function(){
	$(":radio").click(function () {
      var r = $(this).attr("name");
       $(":radio[name=" + r + "]:not(:checked)").attr("tag", 0);
        if ($(this).attr("tag") == 1) {
           $(this).attr("checked", false);
           $(this).attr("tag", 0);
         }
          else {
              $(this).attr("tag",1);
            }
     });
});

猜你喜欢

转载自blog.csdn.net/zwd926/article/details/84757745