5

I am trying to get last unselected value. I have tried many ways but that can give me last selected values (by using last index) not last unselected. Is there any way to do it?

$('#f_district').chosen().change( function(evt, params) {
    if(params.deselected)
    {            
        alert($(this).val());  // it returns null how I can get last unselect value? 
    }
    else
    {
        var arr=$(this).val();
        alert(arr[arr.length-1]);
    }
});
JJJ
  • 32,902
  • 20
  • 89
  • 102
naCheex
  • 1,131
  • 3
  • 14
  • 34

1 Answers1

-1

are you looking some thing like this http://jsfiddle.net/Z2PkZ/1/

var previous;

$(".chosen").one('focus', function () {
    // Store the current value on focus and on change
    previous = this.value;
}).change(function() {
    // Do something with the previous value after the change
     console.log(previous);

    // Make sure the previous value is updated
    previous = this.value;
});
rjdmello
  • 865
  • 2
  • 9
  • 14