I have the following jQuery and I'm confused as to why it's returning -1 and not 0 ? Is anyone able to explain:
var one = $('.test');
var two = $('.test2');
var myArray = [];
myArray.push(one);
if($.inArray($('.test'), myArray) < 0) {
myArray.push(two);
}
console.log($.inArray($('.test'), myArray)); //return -1
I setup http://jsfiddle.net/ecrMw/1/ and I'm trying to return 0 for $('.test') ? That is, find it in the array ?
console.log($.inArray(one, myArray));which does return 0?