The below code snippet explains how to get the selected option from HTML Select dropdown using jQuery
<select id="mySelect">
<option value="1">Yes</option>
<option value="2">No</option>
</select>
<input type="button" id="demo" value = "Demo" />
<script type="text/javascript">
$("#demo").live("click", function () {
//Get selected option of the HTML SELECT
var selectedItem = $("#mySelect option:selected");
//Get the value of the selected option
alert("SelectedItem Value: " + selectedItem.val());
//Get html or text of the selected option
alert("SelectedItem Text: " + selectedItem.html());
});
</script>
Explanation:
The button with ID demo is attached with a click event. When the button is clicked the text or inner HTML and the Value of the selected option of the HTML Select Dropdown with ID mySelect is fetched and displayed in alert.