jQuery Get Selected Option From Dropdown

前端 未结 30 3404
梦如初夏
梦如初夏 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:40

    Set the values for each of the options

    
    

    $('#aioConceptName').val() didn't work because .val() returns the value attribute. To have it work properly, the value attributes must be set on each .

    Now you can call $('#aioConceptName').val() instead of all this :selected voodoo being suggested by others.

提交回复
热议问题