Reputation: 49
I am facing some issue in below mention code. I just want display empty message if the search result is empty. Could you please help me to find the empty results. I mean where should i write the code for empty result.By the way search filter is working perfectly.
var $rows = $('.filters > .article');
$('#search').change(function() {
var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
$rows.show().filter(function() {
var text = $(this).data('location').replace(/\s+/g, ' ').toLowerCase();
return !~text.indexOf(val);
}).hide();
});
Upvotes: 1
Views: 297
Reputation: 31
At the end of your change event handler, you could add...
if($('.filters > .article:visible').length == 0) {
// Search result is empty
}}
Upvotes: 1