/ Published in: jQuery
It's not obvious from the jQuery documentation that `val()` will work to get the currently selected value of a select box (in 1.3.2 at least).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<select id="test-select"> <option value="1" selected="selected">One</option> <option value="2">Two</option> <option value="3">Three</option> </select> <p>Selected value: <span id="selected-value"></span></p> <script type="text/javascript"> jQuery( '#selected-value' ).text( jQuery( '#test-select' ).val() ); // 1 </script>
URL: http://docs.jquery.com/Val