Edit This Code:
<!DOCTYPE html>
<html>
<body>

<select>
  <option label="Volvo">Volvo (Latin for "I roll")</option>
  <option id="myOption" label="Mercedes">Mercedes (Mercedes-Benz)</option>
</select>

<p>Click the button to change the value of the label attribute of the Mercedes option.</p>

<p><b>Tip:</b> Open the drop-down list before and after you have clicked the button.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myOption").label = "newLabel";
    document.getElementById("demo").innerHTML = "The value of the label attribute was changed from 'Mercedes' to 'newLabel'.";
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy