<!DOCTYPE html>
<html>
<body>
<select size="6">
<option value="BMW">BMW</option>
<option value="Mercedes">Mercedes</option>
<optgroup id="myOptgroup" label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="koenigsegg">Koenigsegg</option>
</optgroup>
</select>
<p>Click the button to change the value of the label attribute of the option-group.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("myOptgroup").label = "A Random Car Selection";
}
</script>
</body>
</html>