I'm making a contact list that contains institutions' phones and emails. I put each institution into a div (class="container"). On the top of the page, I put a search input:
<input type="text" id="textFind">
Then I used JQuery to filter the DIVs, according to the input:
//makes contains case insensitive
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
return function(elem) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
//filters divs
$("#textFind").keyup(function() {
var stringPesquisa = $(this).val();
$(".container").hide();
$('div:contains(' + stringPesquisa + ')').show()
});
It's working fine, BUT:
QUESTION 1: I need it to ignore accents (for example: "gerencia" could return "Gerência", "primaria" could return "primária"). I tried many ways to do that, nothing has worked so far. Any ideas?
QUESTION 2: I'm learning Javascript and JQuery, so even the "case insensitive" function is working properly, I just can't understand the code. Could someone explain it?
Thanks in advance! :-)