Tutorial :How determine child ordinal position? Need: $(“#parent”).ordinalChild('#some-child') => 3 (say)


Because Jquery UI tab doesn't support passing id selector to remove() tab method, and no method exists to map id to index, I have to painfully "jump hoops" to determine the index of the tab I wish to remove.

I just searched the documentation for JQuery and wasn't able to find a utility method to return an integer of the ordinal position of some child under a parent. I think I want the functional opposite of the


traversing method (determine index, not select by index).

Does something like this exist?:


This would return 0 if "some-child" is the first child, 1 for the second child, etc.

Or how do I go about obtaining this without writing a loop and counting?


See index

If a selector string is passed as an argument, .index() returns an integer indicating the position of the first element within the jQuery object relative to the elements matched by the selector. If the element is not found, .index() will return -1.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »