+ 11

How to get selected text from select tag using jquery?

14th Feb 2018, 8:55 PM
A͢J
A͢J - avatar
5 ответов
+ 8
It is ok but without passing value we can also get selected text. var value = $("#yourdropdownid option:selected").text();
15th Feb 2018, 5:04 AM
A͢J
A͢J - avatar
+ 5
you can get the value of selected text by using this single line of code $("#select option:selected").text();
15th Feb 2018, 6:55 AM
Ravi Prajapati
Ravi Prajapati - avatar
+ 4
Just like any other value var value = $(”#select”).val(); $(”#select option[value=’” + value + ”’]”).text() <select id=”select”> <option value=”selected”>Value</option> </select> Make sure options have value attr
14th Feb 2018, 11:05 PM
Toni Isotalo
Toni Isotalo - avatar
+ 4
It will get value not text. I want text not value...
15th Feb 2018, 3:49 AM
A͢J
A͢J - avatar
+ 1
Check my edit
15th Feb 2018, 4:33 AM
Toni Isotalo
Toni Isotalo - avatar