Get current value selected in dropdown using jQuery

前端 未结 11 1990
被撕碎了的回忆
被撕碎了的回忆 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:37

    To get the value of a drop-down (select) element, just use val().

    $('._someDropDown').live('change', function(e) {
      alert($(this).val());
    });
    

    If you want to the text of the selected option, using this:

    $('._someDropDown').live('change', function(e) {
      alert($('[value=' + $(this).val() + ']', this).text());
    });
    

提交回复
热议问题