首页 > 其他 > 详细

radio和label关联问题,点击label改变颜色

时间:2015-10-14 17:44:50      阅读:211      评论:0      收藏:0      [点我收藏+]
$(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")
            }
        })
    })
})

  

radio和label关联问题,点击label改变颜色

原文:http://www.cnblogs.com/qinge/p/4877790.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!