Created
June 3, 2010 17:14
-
-
Save StevenBlack/424169 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
// Source: http://www.ferretarmy.com/2010/05/10/extending-jquery-selectors-between/ | |
$.expr[':'].between = function( | |
objNode, | |
intStackIndex, | |
arrProperties, | |
arrNodeStack) | |
{ | |
var args = arrProperties[3].split(","); | |
var startSelector = args[0]; | |
var endSelector = args[1]; | |
var startIndex = -1; | |
var endIndex = -1; | |
// Find the start and end indexes. | |
for (var index = 0; index < arrNodeStack.length; index++) | |
{ | |
if ($(arrNodeStack[index]).is(startSelector) && startIndex < 0) | |
startIndex = index; | |
else if ($(arrNodeStack[index]).is(endSelector) && endIndex < 0) | |
endIndex = index; | |
} | |
if (startIndex >= 0 && | |
endIndex > 0 && | |
intStackIndex > startIndex && | |
intStackIndex < endIndex) | |
return true; | |
else | |
return false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment