Getting value of select (dropdown) before change

来源:互联网 发布:时间同步软件apk 编辑:程序博客网 时间:2024/05/20 20:18

http://stackoverflow.com/questions/4076770/getting-value-of-select-dropdown-before-change

Combine the focus event with the change event to achieve what you want:

(function () {    var previous;    $("select").on('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        alert(previous);        // Make sure the previous value is updated        previous = this.value;    });})();

Working example: http://jsfiddle.net/x5PKf/766


0 0
原创粉丝点击