Cannot retrieve Selected option value
<p>I can able to get the selected option value in onchange event. But, when clicking the ok button in the same page , I can't get the value selected. Please help me.. </p>

<p>Code is as follows: </p>

<pre><code>&lt;select  id ="userstoassign"&gt;
&lt;option value="s1"&gt;S1&lt;/option&gt;
&lt;option value="s2" selected="selected"&gt;S2&lt;/option&gt;
&lt;option value="s3"&gt;S3&lt;/option&gt;
&lt;/select&gt;
&lt;input type="button" name="ok" id="ok" value="ok"/&gt;

$("#ok").live('click', function(){
       var username= $("#userstoassign option:selected").val();
       alert(username);

    });
</code></pre>

<p>Note: In onchange event, I can get the selected value. Temp fix is I'm getting that value in onchange event in a variable and will use it in onclick event. Even in onchange event I'm getting default value if I use the code "$("#userstoassign option:selected").val();"</p>

<pre><code>    $('#userstoassign').live('change',function(){                    selectedUser=this.value;
alert(selectedUser);
    });
</code></pre>
