/ Published in: jQuery
URL: http://docs.jquery.com/Val
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
<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>
You need to login to post a comment.
