I have this array that searches for matches between two arrays. The problem is that it only returns one match and completes. I would like it to return all matches.
Does anyone know why this is only returning once?
var arr1 = $("li a");
var arr2 = $("input").attr('value').split(',');
$.each(arr1, function(i, val) {
if ($.inArray($(val).html(), arr2) !== -1) {
// alert('You got a match!')
}
});
Relevant HTML code:
<input value="Bob Marley, Bob Hanson, Bob Smith" />
<li><a href=#">Bob Marley</a></li>
<li><a href=#">Jeff CookieMonster</a></li>
<li><a href="#">Bob Hanson</a></li>