Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery - determine if ALL multiple select box items are selected?

Tags:

jquery

What is the easiest way to determine if ALL items in a multiple HTML select box are selected?

like image 441
Marcus Leon Avatar asked Nov 29 '10 20:11

Marcus Leon


People also ask

How do I get selected items from select multiple in jQuery?

With jQuery, you can use the . val() method to get an array of the selected values on a multi-select dropdown list.

What is Multiselect in jQuery?

jQuery multiselect is an easier and highly customizable substitute for the standard <select> with the multiple boxes. This is basically a plugin that is more user-friendly and easy to implement when it comes to multiple selections of the checkboxes.

How do you use multiselect?

For windows: Hold down the control (ctrl) button to select multiple options. For Mac: Hold down the command button to select multiple options.


1 Answers

You can check the .length of :not() :selected <option> elements, for example:

var allSelected = $("#selectID option:not(:selected)").length == 0;
like image 159
Nick Craver Avatar answered Sep 19 '22 16:09

Nick Craver