I have a dropdown menu which keeps track of the previous and current selected element. The dropdown default value starts on {0}. When a user changes the dropdown the new_value is stored say {2}, but the previous is always {0} unless the user clicks off the dropdown and then re-focuses on a new value, then the previous updates to that value in this case {2}.
Is there a way I can force the focus to update even if the user never un-focuses the dropdown box, basically on every change event?
(function () {
var previous;
$('select[name=item_a]').focus(function () {
previous = parseInt($(this).val()); }).change(function() {
var new_value = $(this).attr('id');
}
1 Answer