<html>
<head>
<script>
function changeText() {
x = document.getElementById("mySelect");
x.options[x.selectedIndex].text = "Melon";
}
</script>
</head>
<body>
<form>
Select your favorite fruit:
<select id="mySelect">
<option>Apple</option>
<option>Orange</option>
<option>Pineapple</option>
<option>Banana</option>
</select>
<br><br>
<input type="button" onclick="changeText()" value="Set text of selected option">
</form>
</body>
<!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=try_dom_option_settext by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:07:06 GMT -->
</html>