Last active
December 22, 2015 08:09
-
-
Save toledox82/6443241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Live Search | |
function liveSearch() { | |
// Retrieve the input field text and reset the count to zero | |
var filter = $('#search-filter').val(), count = 0; | |
// Loop through the comment list | |
$(".main-list li").each(function(){ | |
// If the list item does not contain the text phrase fade it out | |
if ($(this).text().search(new RegExp(filter, "i")) < 0) { | |
$(this).hide(); | |
// Show the list item if the phrase matches and increase the count by 1 | |
} else { | |
$(this).show(); | |
count++; | |
} | |
}); | |
$("#filter-count").text(count + " domínios"); | |
} | |
$("#search form").submit(function(){ | |
liveSearch(); | |
return false; | |
}); | |
$("#search form").keyup(function(){ | |
setTimeout(function(){ | |
liveSearch() | |
},1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment