Get selected value of a dropdown s item using jQuery

0 votes

How can I get the selected value of a dropdown box using jQuery? I tried using the following lines of code:-

var value = $('#dropDownId').val();

and

var value = $('select#dropDownId option:selected').val();


But however, haven't had any results as both return an empty string.

Feb 18 in Others by Rahul
• 9,680 points
2,795 views

1 answer to this question.

0 votes

To answer your question, start with using a single select dom elements, to get the currently selected value:

$('#dropDownId').val();

To get the currently selected text, use the following line:-
 

$('#dropDownId :selected').text();

answered Feb 18 by Aditya
• 7,660 points

Related Questions In Others

0 votes
1 answer
0 votes
1 answer

Get number of columns of a particular row in given excel using Java

Use: int noOfColumns = sh.getRow(0).getPhysicalNumberOfCells(); Or int noOfColumns = sh.getRow(0).getLastCellNum(); There ...READ MORE

answered Oct 24 in Others by narikkadan
• 37,660 points
119 views
0 votes
1 answer

How to retrieve the value of a text field in Flutter App?

Hi@akhtar, In your TextField, you can call one ...READ MORE

answered Sep 3, 2020 in Others by MD
• 95,380 points
1,007 views
0 votes
1 answer
0 votes
1 answer

How to use jquery with asp.net ajax?

If you weren't aware, Microsoft is planning ...READ MORE

answered Oct 15, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
235 views
0 votes
1 answer

Is 'sparkline' a method?

I suggest you to check 2 things That jquery.sparkline.js is actually ...READ MORE

answered Nov 9, 2018 in Apache Spark by Frankie
• 9,830 points
663 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,510 points
404 views
0 votes
1 answer

Error: Global Variable is not accessable to local function

Hey kartik, A variable declared outside a function has a ...READ MORE

answered Feb 19, 2020 in PHP by Niroj
• 82,800 points
335 views
0 votes
1 answer
0 votes
1 answer

How to style a checkbox using CSS

In modern browsers which include Internet Explorer ...READ MORE

answered Feb 17 in Others by Aditya
• 7,660 points
171 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP