Answers for "how to get text from selected option javascript"

0

how to get text from select tag in javascript

<select id="box1" onChange="myNewFunction(this);">
  <option value="98">dog</option>
  <option value="7122">cat</option>
  <option value="142">bird</option>
</select>
<script>
  function myNewFunction(sel) {
  alert(sel.options[sel.selectedIndex].text);
}
</script>
Posted by: Guest on May-27-2021

Code answers related to "how to get text from selected option javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language