<!DOCTYPE html> | |
<select size=20> | |
<optgroup label=group id=group> | |
<option>apple</option> | |
<option label=banana></option> | |
</optgroup> | |
<option label=cherry></option> | |
</select> | |
<script> | |
var group = document.getElementById('group'); | |
group.appendChild(new Option('durian')); | |
var nestedGroup = document.createElement('optgroup'); | |
nestedGroup.label = 'nested'; | |
nestedGroup.appendChild(new Option('fig')); | |
group.appendChild(nestedGroup); | |
</script> |