简体   繁体   中英

how to get the value from dropdownlist in jQuery

i have a dropdownlist in my web-page how i can get the value from the selected option of them

like

<select id="selme">
<option id="a" value="1">I need it</option>
</select>

how i can get the value "I need it" whenver it will select.

i not talking about attribute "value" i need a value who fill inside option tags of dropdownlist

Try

$("#selme").change(function(){
    $(this).find("option:selected").text();
});

See a working demo

Here is a jsfiddle for you I just made http://jsfiddle.net/AqmZp/

Basically it actually is just $("#selme").val();

试试这个..

$('#selme option:selected').text();

$('#selme option:selected').html()

Check it Out-->

For getting text

$("#selme").change(function(){
 $(this[this.selectedIndex]).text();
});

For getting value

$("#selme").change(function(){
 $(this[this.selectedIndex]).val();
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM