zoukankan      html  css  js  c++  java
  • radio和label关联问题,点击label改变颜色

    $(function () {
        $("#fangan :radio[name='price']").bind('click', function (event) {
            //$(this).next().attr("class", "on");
            $("input[name='price']").each(function () {
                //这里是查找name=checkday的选框并遍历  当然你也可以直接用 $("input:radio")
    
                if ($(this).attr("checked") == "checked") {
                    //这里是判断是否被选中  
                    $(this).next().attr("class", "on")
                }
                else {
                    $(this).next().attr("class", "hide")
                }
            })
        })
        $("#fangan :radio[name='num']").bind('click', function (event) {
            //$(this).next().attr("class", "on");
            $("input[name='num']").each(function () {
                //这里是查找name=checkday的选框并遍历  当然你也可以直接用 $("input:radio")
    
                if ($(this).attr("checked") == "checked") {
                    //这里是判断是否被选中  
                    $(this).next().attr("class", "on")
                }
                else {
                    $(this).next().attr("class", "hide")
                }
            })
        })
        $("#fangan :checkbox[name='model[]']").bind('click', function (event) {
            //$(this).next().attr("class", "on");
            $("input[name='model[]']").each(function () {
                //这里是查找name=checkday的选框并遍历  当然你也可以直接用 $("input:radio")
    
                if ($(this).attr("checked") == "checked") {
                    //这里是判断是否被选中  
                    $(this).next().attr("class", "on")
                }
                else {
                    $(this).next().attr("class", "hide")
                }
            })
        })
        $("#fangan :checkbox[name='color[]']").bind('click', function (event) {
            //$(this).next().attr("class", "on");
            $("input[name='color[]']").each(function () {
                //这里是查找name=checkday的选框并遍历  当然你也可以直接用 $("input:radio")
    
                if ($(this).attr("checked") == "checked") {
                    //这里是判断是否被选中  
                    $(this).next().attr("class", "on")
                }
                else {
                    $(this).next().attr("class", "hide")
                }
            })
        })
    })
    

      

  • 相关阅读:
    css 去除input框边框 鼠标禁用状态 背景颜色
    css 文字边框
    搭建简易的Vue项目
    那些年遇到的Bug
    vue 点击弹出下拉菜单 点击其他页面收回菜单
    css 控制文本显示
    css tips提示框 三角形 + 框
    vue 细节 规范(只要不断片,持续的更新.....)
    @click.self
    工欲善其事,必先利其器
  • 原文地址:https://www.cnblogs.com/qinge/p/4877790.html
Copyright © 2011-2022 走看看