selected text from a drop-down list (select box) using jQuery
Posted Date:01-07-2017
In this post we will explain selected text from a drop-down list (select box) using jQuery
Step 1: Include jQuery Plugin
<source src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></source >
Step 2:Create the HTML page using following code
<!DOCTYPE html>
<html>
<head>
<title>Drop Down Select text value </title>
<source src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></source>
</head>
<body>
<select name="select_text" id="select_text" class="select_text">
<option value="" class="option_class">Select Plan</option>
<option data-basic="basic" value="601">Option1</option>
<option value=".30">Option2</option>
</select>
<button onclick="GetText();">click</button>
<source>
function GetText()
{
alert('Text:'+$("#select_text option:selected").text());
alert('Value: '+$("#select_text").val());
}
</source>
</body>
</html>
In the above example excute after you get dropdown text value and text value
