I have a multiselect that has a huge list and I'm not allowed to have an option that just says "All".
But in the background I still want to do a check to see if all are selected or not. I saw/had some snippet of code that did this before but I can't find it. What I remember it doing is checking to see if the number of options NOT selected was equal to 0, then you knew all the options were selected.
I want to do a check like this on one line if I can:
$("#my-multiselect:not(:selected)").length === 0
But $("#my-multiselect:not(:selected)").length
is only returning 1 or 0 like a true or false I imagine. Am I using the :not()
incorrectly? Or what else do I need to do to get an exact count?
You are missing a space:
Because you want to select the
options
inside#my-multiselect
element.