I have a long list of <a>
tags, and i'd like to filter through them live; that is, to remove the ones that don't match. I'd filter through them based on the text input in an input field. Regex would obviously search the a tag contents for a match to the input field, but i was wondering how to make it fancier, and actively filter the list like google's search bar does these days. I imagine, a key up function would trigger the regex function.
The part i don't know how to do is this:
[input field]ArI[/]
List:
• ArIes
• ArIstotle
i.e., how to make it check the nth letter of the list item.
EDIT
This is what i have so far, and it doesn't work.
$("input.CardName_Input").keyup(function() {
var getPhrase = $(".CardName_Input").val();
new RegExp('^' + getPhrase + '.', 'i');
$("#Results a").each(function() {
if (!($(this).val().match(RegExp))) {
$(this).addClass("HIDE");
}
})
});