Gets the js code for the selected text content of the select element

  • 2020-03-30 01:36:44
  • OfStack

 
var sel=document.getElementById(id);//The id of the select element
var index=sel.selectedIndex;//Gets the index of the selected option
var textsel= sel.options[index].text;//Gets the contents of the corresponding option

Related articles: