jquery - Get combo box selected value -


i have button that, when clicked, should me value of combo box's selected item. example, if have following combo , button:

<select id="client-sort-type">     <option></option>     <option>name</option>     <option>recent</option> </select>  <button id="client-sort-submit" type="button">sort</button> 

i want like...

<script type="text/javascript">     $("#client-sort-submit").click(function () {         var val = $("#client-sort-type").attr("value");         window.location.href = "project/index/" + val;     }); </script> 

only isn't working, returns nothing. help?

use

$("#client-sort-type").val() 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -