Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 按复选框筛选显示/隐藏目标divs jquery_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 按复选框筛选显示/隐藏目标divs jquery

Javascript 按复选框筛选显示/隐藏目标divs jquery,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我在确定jQuery运行时需要显示/隐藏的div时遇到问题 我需要隐藏,正如评论所暗示的,你想做什么还不是很清楚,但我想我明白了。我没有对你的HTML或CSS做任何更改。只是稍微修改了一下JavaScript $('.checkbox').on('click', function (e) { var $this = $(this), $links = $('.checkbox'); if ($this.hasClass('selected')) {

我在确定jQuery运行时需要显示/隐藏的div时遇到问题


我需要隐藏
,正如评论所暗示的,你想做什么还不是很清楚,但我想我明白了。我没有对你的HTML或CSS做任何更改。只是稍微修改了一下JavaScript

$('.checkbox').on('click', function (e) {
    var $this = $(this),
        $links = $('.checkbox');

    if ($this.hasClass('selected')) {
        $this.removeClass('selected');
    } else {
        $this.addClass('selected');
    }

    $('.box').hide();
    if ($(".checkbox:checked").length > 0) {
        // any one is checked
        $.each($links, function (k, v) {
            $this = $(v);
            if ($this.hasClass('selected')) {
                anySelectedCheckbox = true;
                var cat = $this.data('categoryType');
                var nam = $this.data('categoryName');
                $('.box:has(div[data-category-type="' + cat + '"],div[data-category-name="+nam+"] )').show();
            }

        });
    } else {
        // none is checked
        $('.box').show();
    }
});

正如评论所暗示的,你想做什么并不十分清楚,但我想我明白了。我没有对你的HTML或CSS做任何更改。只是稍微修改了一下JavaScript

$('.checkbox').on('click', function (e) {
    var $this = $(this),
        $links = $('.checkbox');

    if ($this.hasClass('selected')) {
        $this.removeClass('selected');
    } else {
        $this.addClass('selected');
    }

    $('.box').hide();
    if ($(".checkbox:checked").length > 0) {
        // any one is checked
        $.each($links, function (k, v) {
            $this = $(v);
            if ($this.hasClass('selected')) {
                anySelectedCheckbox = true;
                var cat = $this.data('categoryType');
                var nam = $this.data('categoryName');
                $('.box:has(div[data-category-type="' + cat + '"],div[data-category-name="+nam+"] )').show();
            }

        });
    } else {
        // none is checked
        $('.box').show();
    }
});

正如评论所暗示的,你想做什么并不十分清楚,但我想我明白了。我没有对你的HTML或CSS做任何更改。只是稍微修改了一下JavaScript

$('.checkbox').on('click', function (e) {
    var $this = $(this),
        $links = $('.checkbox');

    if ($this.hasClass('selected')) {
        $this.removeClass('selected');
    } else {
        $this.addClass('selected');
    }

    $('.box').hide();
    if ($(".checkbox:checked").length > 0) {
        // any one is checked
        $.each($links, function (k, v) {
            $this = $(v);
            if ($this.hasClass('selected')) {
                anySelectedCheckbox = true;
                var cat = $this.data('categoryType');
                var nam = $this.data('categoryName');
                $('.box:has(div[data-category-type="' + cat + '"],div[data-category-name="+nam+"] )').show();
            }

        });
    } else {
        // none is checked
        $('.box').show();
    }
});

正如评论所暗示的,你想做什么并不十分清楚,但我想我明白了。我没有对你的HTML或CSS做任何更改。只是稍微修改了一下JavaScript

$('.checkbox').on('click', function (e) {
    var $this = $(this),
        $links = $('.checkbox');

    if ($this.hasClass('selected')) {
        $this.removeClass('selected');
    } else {
        $this.addClass('selected');
    }

    $('.box').hide();
    if ($(".checkbox:checked").length > 0) {
        // any one is checked
        $.each($links, function (k, v) {
            $this = $(v);
            if ($this.hasClass('selected')) {
                anySelectedCheckbox = true;
                var cat = $this.data('categoryType');
                var nam = $this.data('categoryName');
                $('.box:has(div[data-category-type="' + cat + '"],div[data-category-name="+nam+"] )').show();
            }

        });
    } else {
        // none is checked
        $('.box').show();
    }
});


你想实现什么目标?目前,这个问题有点模糊,无法回答。我通过更改var selectedDivs=$('.grid cell').hide()解决了这个问题;修改我的html代码我的解决方案可能更干净,所以接受它并投票支持我。:)花了一点时间…你想达到什么目的?目前,这个问题有点模糊,无法回答。我通过更改var selectedDivs=$('.grid cell').hide()解决了这个问题;修改我的html代码我的解决方案可能更干净,所以接受它并投票支持我。:)花了一点时间…你想达到什么目的?目前,这个问题有点模糊,无法回答。我通过更改var selectedDivs=$('.grid cell').hide()解决了这个问题;修改我的html代码我的解决方案可能更干净,所以接受它并投票支持我。:)花了一点时间…你想达到什么目的?目前,这个问题有点模糊,无法回答。我通过更改var selectedDivs=$('.grid cell').hide()解决了这个问题;修改我的html代码我的解决方案可能更干净,所以接受它并投票支持我。:)这花了一点时间…足够近,完全符合我的要求,但我意识到我需要隐藏
网格单元
,使其正常工作。Thansk1更干净,更容易理解。为了提高可读性,OP应该考虑使用这个解决方案。你得到了我的支持。足够接近,完全符合我的要求,但我意识到我需要隐藏
网格单元
,使其正常工作。Thansk1更干净,更容易理解。为了提高可读性,OP应该考虑使用这个解决方案。你得到了我的支持。足够接近,完全符合我的要求,但我意识到我需要隐藏
网格单元
,使其正常工作。Thansk1更干净,更容易理解。为了提高可读性,OP应该考虑使用这个解决方案。你得到了我的支持。足够接近,完全符合我的要求,但我意识到我需要隐藏
网格单元
,使其正常工作。Thansk1更干净,更容易理解。为了提高可读性,OP应该考虑使用这个解决方案。我投你一票。