Get current value selected in dropdown using jQuery

前端 未结 11 1978
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 11:59

I have a set of dynamically generated dropdown boxes on my page. basically I clone them using jQuery. now I want to capture the value selected on each dropdown on change eve

11条回答
  •  庸人自扰
    2020-12-13 12:41

    This is what you need :)

    $('._someDropDown').live('change', function(e) {
        console.log(e.target.options[e.target.selectedIndex].text);
    });
    

    For new jQuery use on

    $(document).on('change', '._someDropDown', function(e) {
        console.log(this.options[e.target.selectedIndex].text);
    });
    

提交回复
热议问题