Help comparing 2 arrays in jquery
// I'VE GOT two arrays. I want to iterate through itms in the second array to see if an item from the second arry is present in the first array. If it is present I want to effect a function ( alert("jjjj")) and then iterate to the next item and so forth. tx -dave
$(document).ready(function () {
alert("wtfH");
var arr1 = ["red", "blue", "green"];
var arr2 = ["yellow", "blue", "black", "red", "teal", "green"];
$(arr2).each(function () {
//alert(this);
alert(jQuery.inArray(this, arr1));
if (jQuery.inArray(this, arr1) != -1) {
alert("jjjj");
}
});
}); //END READY