Wednesday, September 28, 2011

index(Element)

index(Element subject) returns Number
Searches every matched element for the object and returns the index of the element, if found, starting with zero. Returns -1 if the object wasn't found.
Example:
Returns the index for the element with ID foobar
$("*").index( $('#foobar')[0] )

HTML:
<div id="foobar"><b></b><span id="foo"></span></div>

Result:
0

No comments:

Post a Comment