使用一个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);
  }
 });

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2021-06-02
  • 2022-12-23
  • 2021-04-18
  • 2021-09-03
相关资源
相似解决方案