jQuery Get Selected Option From Dropdown

前端 未结 30 4084
梦如初夏
梦如初夏 2020-11-22 02:56

Usually I use $(\"#id\").val() to return the value of the selected option, but this time it doesn\'t work. The selected tag has the id aioConceptName

30条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 03:31

    I hope this also helps to understand better and helps try this below,

    $('select[id="aioConceptName[]"] option:selected').each(function(key,value){
       options2[$(this).val()] = $(this).text();
       console.log(JSON.stringify(options2));
    });
    

    to more details please http://www.drtuts.com/get-value-multi-select-dropdown-without-value-attribute-using-jquery/

提交回复
热议问题