Reputation: 56669
What is the easiest way to determine if ALL items in a multiple HTML select box are selected?
Upvotes: 9
Views: 6644
Reputation: 63512
check if the number of not selected is zero and if there are at least 1 option
var all = $("select :not(:selected)").length == 0 && $("select options").length > 0;
Upvotes: 1
Reputation: 630379
You can check the .length
of :not()
:selected
<option>
elements, for example:
var allSelected = $("#selectID option:not(:selected)").length == 0;
Upvotes: 19