开发者

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


http://groups.google.com/group/jquery-en/browse_thread/thread/2970457bc8ec7ec5?pli=1

All there for you


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

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


Check it Out-->

For getting text

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

For getting value

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


Try this..

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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜