How do I ignore case sensitivity with the :contains() Selector?
$('.css-label:contains("' + filter + '")').each(function () {
$(this).show();
$(this).prev().show().prev().show().closest(".search-recipe-chkbox").css("display", "inline-block");;
});
Context
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();
});
Thank you