How to get select box option value?

Here is my code:


<select name=“optionList” id=“optionList” size=“5”>
<option value=“1”>1</option>
<option value=“2”>2</option>
<option value=“3”>3</option>


$(document).ready(function(event) {
$(‘#optionList’).on(‘mouseenter’, ‘option’, function(e) {

[B][COLOR="#FF0000"]alert(option.mouseentered.value); // This does not work . What is the correct code ?[/COLOR][/B]



You want this.value.

Also, rather than using the mouseenter event, it would be better to bind to the change event of the select tag, then it will work for keyboard users too.