how when i click apple
Apple's text area, not the number.
function getIndex() {
document.getElementById("demo").innerHTML =
document.getElementById("mySelect").selectedIndex;
}
<select id="mySelect"><option>Apple</option><option>Orange</option><option>Pineapple</option><option>Banana</option></select><input type="button" onclick="getIndex()" value="Display the index of the selected option"><p id="demo"></p>
I compile the value in the select option, I want the text to come out instead of the number