Steven Spielberg
Steven Spielberg

Reputation:

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

Upvotes: 4

Views: 1083

Answers (6)

rtconner
rtconner

Reputation: 1237

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

Upvotes: 0

Vivek
Vivek

Reputation: 11028

Try this..

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

Upvotes: 0

Sukhjeevan
Sukhjeevan

Reputation: 3156

Check it Out-->

For getting text

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

For getting value

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

Upvotes: 0

wmitchell
wmitchell

Reputation: 5735

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

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

Upvotes: 0

rahul
rahul

Reputation: 187110

Try

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

See a working demo

Upvotes: 6

Related Questions