How to get label of select option with jQuery?

Viewed 155798
<select>
<option value="test">label </option>
</select>

The value can be retrieved by $select.val().

What about the label?

Is there a solution that will work in IE6?

11 Answers

Try this:

$('select option:selected').text();

I found this helpful

$('select[name=users] option:selected').text()

When accessing the selector using the this keyword.

$(this).find('option:selected').text()

In modern browsers you do not need JQuery for this. Instead use

document.querySelectorAll('option:checked')

Or specify any DOM element instead of document

<SELECT id="sel" onmouseover="alert(this.options[1].text);"
<option value=1>my love</option>
<option value=2>for u</option>
</SELECT>
Related