:contains() 选择器 - 如何忽略区分大小写?

如何使用 :contains() 选择器忽略区分大小写?

            $('.css-label:contains("' + filter + '")').each(function () {
                $(this).show();
                $(this).prev().show().prev().show().closest(".search-recipe-chkbox").css("display","inline-block");;
            });

上下文

        var input = $('.search-filter');
        input.change(function () {
            var filter = input.val().toLowerCase();
            if (filter.length == 0) { // show all if filter is empty
                $('.css-label').each(function () {
                    $(this).show();
                    $(this).prev().show().prev().show().closest(".search-recipe-chkbox").css("display","inline-block");
                });
                return;
            }

            // hide all labels with checkboxes
            $('.css-label').each(function () {
                $(this).hide();
                $(this).prev().hide().prev().hide().closest(".search-recipe-chkbox").css("display","none");;
            });

            // show only matched
            $('.css-label:contains("' + filter + '")').each(function () {
                $(this).show();
                $(this).prev().show().prev().show().closest(".search-recipe-chkbox").css("display","inline-block");;
            });
        }).keyup(function () {
            $(this).change();
        });

谢谢

shuojie 回答::contains() 选择器 - 如何忽略区分大小写?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/229.html

大家都在问