jQuery get selected item
Posted on 2012-04-09
I have a form with a simple dropdown box.
I'm trying to use jQuery to get the value of the currently selected item.
var accountcode = $('select#accountdropdown').val();
var accountcode = $('select#accountdropdown:selected').val();
and a few other variations and no matter the change I still get only the first value in the drop down box even if it's not selected. For instance CODE1 will always be returned.
<select name="shippingdropdown" id="shippingdropdown" class="large-input">