How can I get the selected value of a dropdown box using jQuery?
I tried using
var value = $(\'#dropDownId\').val();
and
Use the method below to get the selected value on page load:
$(document).ready(function () {
$('#ddlid').on('change', function () {
var value = $('#ddlid :selected').text();
alert(value);`
});
});
$("#dropDownId").val('2');
var SelectedValue= $("#dropDownId option:selected").text();
$(".ParentClass .select-value").html(SelectedValue);
<p class="inline-large-label button-height ParentClass" >
<label for="large-label-2" class="label">Country <span style="color: Red;">*</span><small></small></label>
<asp:DropDownList runat="server" ID="dropDownId " CssClass="select" Width="200px">
</asp:DropDownList>
</p>
For selected text use:
value: $('#dropDownId :selected').text();
For selected value use:
value: $('#dropDownId').val();
$("select[id$=dropDownId]").val()
You need to put like this.
$('[id$=dropDownId] option:selected').val();
use
$('#dropDownId').find('option:selected').val()
This should work :)