Created
March 11, 2012 17:54
-
-
Save pifantastic/2017409 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Determine the position of an element within | |
// the matched set of elements | |
index: function( elem ) { | |
// No argument, return index in parent | |
if ( !elem ) { | |
return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; | |
} | |
// index in selector | |
if ( typeof elem === "string" ) { | |
return jQuery.inArray( this[0], jQuery( elem ) ); | |
} | |
// Locate the position of the desired element | |
return jQuery.inArray( | |
// If it receives a jQuery object, the first element is used | |
elem.jquery ? elem[0] : elem, this ); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment