how to iterate through multiple select options with jquery

后端 未结 6 2112
走了就别回头了
走了就别回头了 2021-02-18 13:22

I was just wondering if it\'s possible to go through multiple select options and get their values and text(if one is selected get the value and text, if 2 is selected get both o

6条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-18 13:53

    https://jsfiddle.net/kmgoddard/Lfkvm3ar/4/

    $("#mybutton").click(function(){
    list = new Array();
    $('select > option:selected').each(function() {
    
      list.push($(this).val());
    
    });
     alert(list.toString());
    });
    

提交回复
热议问题