How to Get Text Value of a Selected Option

Let’s try to explain this by example. Look at the following <select> structure:

If you want to get the value of the currently selected item with jQuery is actually simple:

$( "#myselect" ).val();
// => 1

What if you want to get the text of the selected item?

$( "#myselect option:selected" ).text();
// => "Renault"

No comments:

Post a Comment