Skip to content

Instantly share code, notes, and snippets.

@rcmachado
Created May 17, 2010 13:55
Show Gist options
  • Save rcmachado/403780 to your computer and use it in GitHub Desktop.
Save rcmachado/403780 to your computer and use it in GitHub Desktop.
A simple jQuery plugin that selects all options on a <select multiple>
(function ($){
$.fn.selectAll = function (selector) {
var sel = selector || 'option';
$(sel, this).each(function () {
if (this.disabled) {
this.selected = false;
} else {
this.selected = true;
}
});
}
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment