I have a multi-select that contains many sources where the visitor came from. I also enable the option (with the value "all") at the top of all options.
When someone clicks this option, then all options will be selected. And this part is simple. I have included multi-select and jquery that listen for the click event.
<select name="sourceid[]" id="sourceid" style="width:230px;" multiple="multiple"> <option value="all">-- Select All Sources --</option> <option value="1">Internet</option> <option value="2">Radio</option> <option value="3">Phone</option> <option value="4">Other</option> </select> $("#sourceid").click(function(){ if($(this).val()=='all'){ $("#sourceid option").attr("selected","selected"); } });
So far, this works great! For example, jquery also selects the top option.
Is there any way to tell jquery to exclude a single option?
source share