- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get selected text from a drop-down list (select box) using jQuery?
With jQuery, it’s easy to get selected text from a drop-down list with :selected. This is done using the select id. You can try to run the following code to learn how to get selected text from a drop-down list using jQuery −
Example
<html> <head> <title>jQuery Selector</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#submit").click(function(){ $("#myselection option:selected").text(); alert( $("#myselection option:selected").text() ); }); }); </script> </head> <body> <div> <p>The selected value:</p> <select id="myselection"> <option value="1">First</option> <option value="2">Second</option> </select> <button id="submit">Result</button> </div> </body> </html>
- Related Articles
- How can I get the selected value of a drop-down list with jQuery?
- How to select value from a drop down using Selenium IDE?
- How to select/get drop down option in Selenium 2?
- How to get all options in a drop-down list by Selenium WebDriver using C#?
- How to Only Allow Numbers in a Text Box using jQuery?
- How to define a drop-down list in HTML5?
- How to change font style using drop-down list in JavaScript?
- How to pass Drop Down Box Data to Python CGI script?
- How to select a drop-down menu option value with Selenium (Python)?
- How to add color to a drop-down list in Excel?
- Passing Drop Down Box Data to CGI Program in Python
- How to Add a Blank Option to a Drop-Down List in Excel?
- How to include an option in a drop-down list in HTML?
- How to populate select list with jQuery?
- How to remove underline from text hyperlink using jQuery?

Advertisements