Search elements based on data attributes. I have the following code and would like to know, how can this be achieved if the data attribute value with space
<div class="data" data-value="auto"> abcd </div>
<div class="data" data-value="simple tab,block"> acd </div>
<div class="data" data-value="auto"> abd </div>
<div class="data" data-value="block"> abcde </div>
<div class="null-data"> type the correct value </div>
<input class="search-text" name="keyword" type="text" id="search-keyword" placeholder="search">
On typing input value event I basically want to find out all the items that belong to a specific data-value?
$('#search-keyword').on( "keyup", function() {
$('.null-data').hide();
if($(this).val()) {
var input = $(this).val().toLowerCase();
$(".data").hide();
$(".data[data-value*="+ input +"]").show();
if(!$('.data:visible').get(0)){
$('.null-data').show();
}
}else{
$('.null-data').show();
}
});
I'm getting the html elements based on data attribute values but if the data attribute value has space, the html elements are not showing up.