I am having a problem with matching elements in jQuery.
Basically I have list items, and onclick
I want to compare two elements to find out its position within the list, ie.
<ul id="someID">
<li>something</li>
<li>something</li>
<li>something</li>
</ul>
// here is the script
var row = 0,
element = $('#someID > li:eq(1)').get(0);
$('#someID > li').each(function(index, value) {
if (value == element) {
row = index;
return false;
}
}
element
is in the proper scope and this all should work (or so I think). The only reason I can see that it might not work is that the browser sees each list-item
as the same, because its innerHTML
is the same and has no id
or class
.
Is there some other way that I can get the position of a list-item within a list?