I have an array (myElems) with objects (list items).
I'd like to fish out from this array an element with ID matching 'foo'.
'foo' string is currently stored in a var 'targetItem'
Last, I need to grab that matching element's position.top
var targetItem = 'foo'; // value of this var is set dynamically
$(myElems).grep(function(ele){
retun ele.id == menuItem;
});
var loc = // [returned from array].position.top;
...yes, I know this is hodgepodge... I don't know how to syntax this
Thanks
EDIT: creation of myElems
var myElems = [];
$('#menu').children('li').each(function() {
myElems.push( $(this) );
});
html:
<ul id="menu">
<li id="foo">FOO ITEM</li>
<li id="boo">BOO ITEM</li>
</ul>