Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Keep only list items containing the search term function filterList(term) { $('#results li').hide().filter(function () { return $(this).text().toLowerCase().indexOf(term) !== -1; }).show(); } $('#search').on('input', function () { filterList($(this).val().toLowerCase()); }); // Keep items with a price above 50 $('#products .item').filter(function () { return parseFloat($(this).data('price')) > 50; }).addClass('premium'); // Keep elements taller than 200 px $('article').filter(function () { return $(this).outerHeight() > 200; }).addClass('long-read');
Result
Open