zoukankan      html  css  js  c++  java
  • 多个单选框选中

     使用一个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);
      }
     });
  • 相关阅读:
    类继承
    抽象基类 纯虚函数
    虚函数
    Java网络通信
    Java补补补
    刷LeetCode吧
    贝叶斯网络的
    vscode添加vue模板
    vue--项目实例
    Java01
  • 原文地址:https://www.cnblogs.com/intangible/p/6692435.html
Copyright © 2011-2022 走看看