I’m using jQuery to listen to changes to a <select multiple> element. Is there some way of determining, from the event I’m given, which options in the select have changed (been selected or de-selected)?
I know I can loop over the select‘s children to figure out which are selected, but I specifically need to know which ones have just been changed when the event comes in.
So, for example, if the select contains the options { A, B, C }, I need to be able to tell when the user control-clicks to add B to the selection, or when the user clicks normally to change the selection from { A, B } to C alone.
Well, AFAIK you cannot do it by any simple way. As user can select multiple options by draging or using keyboard etc. However you can store the default state of the SELECT into an array of selected options/IDs and compare/update it whenever onchange event is fired.