Binding event to chosen select

笑着哭i 提交于 2019-12-03 22:51:40
Tats_innit

Code:

$(".chzn-select").chosen().change(function() {
    alert(+$(this).val());
    //$('#' + $(this).val()).show();
});

Demo:

Working demo: http://jsfiddle.net/MM7wh/

Edit (6th July 2015)

cdns are changed now.

Working demo: http://jsfiddle.net/uk82dm5L/

Please use $(this).val() instead of .text().

user7051905

Personally I prefer use this:

$(document).on('change', '#mychosen', function(evt, params) {
    if (params.selected != undefined)
    {
        console.log('selected: ' + params.selected);
    }
    if (params.deselected != undefined)
    {
        console.log('deselected: ' + params.deselected);
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!