I have an html document with the field to filter text in blocks. Here is my code:
JS:
$('#search-input').on('keyup', function() {
var filter = $(this).val();
var results = $('#icons section > .fontawesome-icon-list > .fa-hover:Contains("' + filter + '")');
console.log(results);
$('#results .row').html(results);
$('#results').show();
});
The filtered data is output in block #results .row.
The script works correctly only the first time (the first event 'keyup'). How to make so that at every event 'keyup' it filter the data correctly?
You need to clone the results:
var results = $('#icons section > .fontawesome-icon-list > .fa-hover:Contains("' + filter + '")').clone();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With