Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created August 8, 2012 09:27
Show Gist options
  • Save netsi1964/3293753 to your computer and use it in GitHub Desktop.
Save netsi1964/3293753 to your computer and use it in GitHub Desktop.
jQuery psedu-selectors
/*
Sten Hougaard, 2012-08-08
29/05/2014 10.55: Updated
Extends jQuery with psedu-selector:
:between(iFrom, iTo)
Will return elements which has position between iFrom and iTo.
*/
(function($) {
$.extend($.expr[':'], {
between: function(element, index, matches, set) {
var fromTo =matches[3].split(',');
return (index>=fromTo[0] && index<=fromTo[1]);
}
});
})(jQuery);
/*
Sten Hougaard, 2012-12-05
Extends jQuery with psedu-selector:
:emptyValue
Will return true if a trimmed value of an element is empty.
*/
(function($) {
$.extend($.expr[':'],{
emptyValue: function(element, index, matches, set){
return $.trim($(element).val()) === "";
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment