1
0
mirror of https://github.com/Llewellynvdm/front-end-frameworks.git synced 2024-06-26 15:14:07 +00:00
front-end-frameworks/js/search.js
2013-12-14 09:55:08 -06:00

25 lines
565 B
JavaScript

$(document).ready(function(){
$("input#search").keyup(function(){
var query = $(this).val();
if (!query) {
$("#comparisonTable div.parent").show();
$("#noSearch").hide();
return;
}
var regex = new RegExp(query, "ig"), count = 0;
$("#comparisonTable div.parent:not(#noSearch)").each(function(){
if ($(this).text().search(regex) < 0) {
$(this).hide();
} else {
$(this).show();
count += 1
}
});
if (count == 0) {
$("#noSearch span").text(query)
$("#noSearch").show();
} else {
$("#noSearch").hide();
}
});
});