Home >Web Front-end >JS Tutorial >jQuery or Js gets the selected value or text
jquery
Get the text value $("#select1 option:selected").text();
Get the value $("#select1 option:selected").val();
js
var obj = document. getElementById(”selectId”); //Location id
var index = obj.selectedIndex; //Select the index
Get the text value
var text = obj.options[index].text; //Select the text
Get the value
var value = obj.options[index].value;