JSFiddle - React, Tailwind, and code Playground
by mowglisanu
HTML
<form>
<select multiple onchange="myFunction(this)">
<option>Apple</option>
<option>Orange</option>
<option>Pineapple</option>
<option>Banana</option>
</select>
</form>
<p id="demo"></p>
JavaScript
function myFunction(selTag){
var x = selTag.options[selTag.selectedIndex].text;
selTag.options[selTag.selectedIndex].text = "value";
//selTag.options[selTag.selectedIndex].innerHTML = "value";
document.getElementById("demo").innerHTML="You selected: " + x;
}