A couple of weeks ago, a client of ours needed a simple way to select some or all options in a multiple select form element that contained hundreds of options. Basically, they had various State/County combination’s that they needed to assign to different pieces of content.
So Article X might need to select all Counties in State Y. In other cases, an article might simply need to be tagged will all available options in a particular select element. The point is, holding the Command key and clicking through hundreds of select options was becoming a bit tedious. They asked if there was a an easier way. jQuery to the rescue! So here are the tasks that I needed jQuery to help with:
Select all elements with a single click
Deselect all elements with a single click
Select elements that match some value. (contain “red”) with a single click