Dropdown change events and selectedIndex
Today I learned how to listen to
<select> change events, and store
I had never heard of the
selectedIndex method, so I checked out the documentation on the mozilla developer network.
I’m not sure this is super useful outside the context of dropdown menus, but it’s a heck of a lot easier
than looking for
selected attributes and removing them, which can be a pain to manage.
Instead, you can just set
-1, which will deselect all options.