I have the following dropdown list:
Since everyone else has proposed basically the same solution, here's a simpler solution if you have the benefit of only targeting modern browsers:
var el = document.querySelector('select[name=DD1] option[value=D]');
el.parentNode.removeChild(el);
Or, for every browser:
var el;
if(typeof document.querySelector == 'function') {
el = document.querySelector('select[name=DD1] option[value=D]');
} else {
for(var child in document.getElementById('DD1').childNodes) {
if(child.textContent == 'D') {
el = child;
break;
}
}
}
el && el.parentNode.removeChild(el);