zoukankan      html  css  js  c++  java
  • 判断一组checkbox/redio是否被选中,为其添加样式

    业务场景:当一行中有一个CheckBox被选中,则为此行添加class。

    <script type="text/javascript">
    $(function(){
        $("input[type='radio']").click(function(){
           $(this).parent("td").parent("tr").addClass("info");
        });
    
     $("input[type='checkbox']").click(function(){
        var s = $("input[name='name']");
        var boxChecked=false;
        s.each(function(i) {
            if(this.checked==true){
               boxChecked=true;
            }
        });
        if(boxChecked){
            $(this).parent("td").parent("tr").addClass("info");
        }else{
            $(this).parent("td").parent("tr").removeClass("info");
        }
     });
    });
    </script>
  • 相关阅读:
    初始化项目结构
    Django基础2
    Django基础
    Linux(9~)
    Linux(8~)
    redis案例
    Jedis连接池
    Jedis入门
    redis持久化
    redis命令操作
  • 原文地址:https://www.cnblogs.com/shaozhiqi/p/11535050.html
Copyright © 2011-2022 走看看