Get the value of a dropdown in jQuery

后端 未结 10 2313
臣服心动
臣服心动 2020-11-29 02:46

I have a drop down that has an \'ID, Name\' Pair.

Example

Jon Miller
Jim Smith
Jen Morsin

Jon MIller has ID of 101
Jim Smith has ID of 10

10条回答
  •  感情败类
    2020-11-29 03:21

    The best way is to use:

    $("#yourid option:selected").text();
    

    Depending on the requirement, you could also use this way:

    var v = $("#yourid").val();
    $("#yourid option[value="+v+"]").text()
    

提交回复
热议问题