4

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

6 Answers 6

6

Try

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

See a working demo

Sign up to request clarification or add additional context in comments.

4 Comments

ack, I was about to write a similar answer, but you beat me to it :)
too complicated, $('#selme').val(); is pretty enough!
This won't fetch the correct result in the context mentioned. This will fecth the value and not the text.
@Andreyco .val() won't get the "I need it" string
0

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

All there for you

Comments

0

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

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

Comments

0

Check it Out-->

For getting text

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

For getting value

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

Comments

0

Try this..

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

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.