jQuery get value of select onChange

0 votes
I was under the impression that I could get the value of a select input by doing this $(this).val(); and applying the onchange parameter to the select field.

It would appear it only works if I reference the ID.

How do I do it using this.
Jun 22 in Web Development by gaurav
• 13,460 points
14 views

1 answer to this question.

0 votes

Try this-

$('select').on('change', function() {
  alert( this.value );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<select>
    <option value="1">One</option>
    <option value="2">Two</option>
</select>
answered Jun 23 by rajatha
• 4,940 points

Related Questions In Web Development

0 votes
1 answer

How to get value of HTML Checkbox from onclick/onchange events?

Hello @kartik, Use the click event, which won't fire until ...READ MORE

answered Oct 7, 2020 in Web Development by Niroj
• 82,720 points
3,177 views
0 votes
1 answer

jQuery get value of selected radio button

Input Radio value Property Get the value of ...READ MORE

answered Jun 23 in Web Development by rajatha
• 4,940 points
6 views
0 votes
1 answer

Get checkbox value in jQuery

To get the value of the Value ...READ MORE

answered Jun 23 in Web Development by rajatha
• 4,940 points
7 views
0 votes
1 answer

Get checkbox value in jQuery

if you have set a class or id for it, you ...READ MORE

answered Jun 23 in Web Development by rajatha
• 4,940 points
6 views
0 votes
1 answer

jQuery get value of select onChange

Try the following lines of code- $('select').on('change', function() ...READ MORE

answered Feb 11 in Java by Soham
• 8,730 points
81 views
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
174 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
574 views
0 votes
1 answer

What is the syntax of SELECT statement?

This statement is used to select data ...READ MORE

answered Nov 27, 2018 in Database by Sahiti
• 6,380 points
396 views
0 votes
1 answer

jQuery get value of select onChange

To get the value and text of ...READ MORE

answered Jun 23 in Web Development by rajatha
• 4,940 points
8 views
0 votes
1 answer

$("#select option:second").val() jquery - keep select second value of select box option

Yes, you want the special jQuery eq() selector. ...READ MORE

answered Jun 22 in Web Development by rajatha
• 4,940 points
5 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP