I have a number of select boxes that have been set to accept multiple values. Is there anyway that I can use jQuery to get the last selected value? I\'ve tried using the f
Use the :last selector:
var latest_value = $("option:selected:last",this).val();
It may be that this
in the context of the callback function doesn't refer to the element itself, but instead to an element within it, so try the following:
var latest_value =
$(this).closest('select').find('option').filter(':selected:last').val();
It may also be worth calling console.log(this);
inside the callback function, just so you know what element you're actually working with.