You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find myself needing to figure out an element's ordering among its siblings often enough to consider a universal method for it. Consider the following DOM
The command $('first').index() would return 0, that element's position among its siblings. However, this function wouldn't consider tag types by design. Faced with a mixed tag type collection it still returns the index, but if the user wants nth-of-type they would have to use the proposed sibling function indexOfType.
<div><divid="first">Hello there</div><sectionid="second"> Sectioning</section><articleid="third"> articles</article><divid="fourth"> and so on.</div></div>
With the DOM above $('fourth').index() returns "3". $('fourth').indexOfType() returns "1" since it is the second div tag in the group.
Activity