Take a look at this fiddle: http://jsfiddle.net/8HHvf/
HTML
<ul id='myUL'>
<li id="a"></li>
<li id="b"></li>
<li id="c"></li>
<li id="d"></li>
<li id="e"></li>
</ul>
JS
var arr = [];
$a=$('#a');
arr.push($a);
$a=$('#b');
arr.push($a);
$a=$('#d');
arr.push($a);
$a=$('#e');
arr.push($a);
console.log(arr);
if(jQuery.inArray($('li#b'),arr)!=-1){
console.log('aurica!!!');
}
I am populating an array with jQuery objects but the inArray method does not find an object.
This code suppose to write "aurica!!!" but it doesn't.
do you have any idea why, and more impotent how can I find a jQuery object inside an array???
$('li#b')is a totally different object from any saved variable you put in the array.