jQuery get select option text

Posted by Paolo Bergantino on Stack Overflow See other posts from Stack Overflow or by Paolo Bergantino
Published on 2008-10-13T04:06:34Z Indexed on 2010/03/23 19:53 UTC
Read the original article Hit count: 553

Filed under:
|

Alright, say I have this:

<select id='list'>
<option value='1'>Option A</option>
<option value='2'>Option B</option>
<option value='3'>Option C</option>
</select>

What would the selector look like if I wanted to get "Option B" when I have the value '2'. Please note that this is not asking how to get the selected text value, but just any one of them, whether selected or not, depending on the value attribute. I tried:

$("#list[value='2']").text();

But it is not working.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript