如何从jQuery中的dropdownlist获取值

时间:2011-01-24 11:02:01

标签: javascript jquery html events drop-down-menu

我的网页上有一个下拉列表,我如何从他们选择的选项中获取值

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

如何在选择时获得“我需要它”的价值。

我不是在谈论属性“价值”我需要一个填充下拉列表选项标签的值

6 个答案:

答案 0 :(得分:6)

尝试

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

查看working demo

答案 1 :(得分:0)

答案 2 :(得分:0)

这里有一个jsfiddle,我刚刚制作了http://jsfiddle.net/AqmZp/

基本上它实际上只是$(“#selme”)。val();

答案 3 :(得分:0)

试试这个..

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

答案 4 :(得分:0)

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

答案 5 :(得分:0)

检查出来 - &gt;

获取文字

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

获取价值

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