jQuery get value of selected option


To access the value of the selected option from the the select dropdown list is easy, in jQuery, you can use the val() function to get the value, here is an example of how to use it:

<select id="myselect">
   <option value="1">Mr</option>
   <option value="2">Mrs</option>
   <option value="3">Ms</option>
   <option value="4">Dr</option>
   <option value="5">haseeb</option>
 </select>
$("select#myselect").change( function() {
    alert($("select#myselect").val());
});

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Technorati
  • Twitter
  • Yahoo! Bookmarks

  1. No comments yet.
(will not be published)