Created
April 13, 2011 15:51
-
-
Save filipsalo/917801 to your computer and use it in GitHub Desktop.
Untested plugin for getting the inverse of the last selection in jQuery
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
(function($) { | |
$.fn.inverse = function() { | |
var prevSelector = this.prevObject.selector, | |
suffix = this.selector.slice(prevSelector.length); | |
if (suffix.charAt(0) === " ") { | |
// Last action was a find | |
return this.prevObject.find(":not(" + suffix.slice(1) + ")"); | |
} else { | |
return this.prevObject.not(this); | |
} | |
} | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment