多个单选框选中

 使用一个js代码实现多个单选按钮的选中事件。 

<input type="radio" name="xxx" id="xxx" value=""/>


$("input:radio").click(function() {
  var tag = $(this).attr("tag");
  if(tag != "1") { //未选中默认,
    //设置相同name的其余的都为0
    var n = $(this).attr("name");
    $("input[name='" + n + "']").attr("tag", "0");
    $(this).attr("tag", "1");
    $(this).attr("checked", true);
  } else {
    $(this).attr("tag", "0");
    $(this).attr("checked", false);
  }
 });
原文地址:https://www.cnblogs.com/intangible/p/6692435.html