HTML

<select name="selectt" id="select" class="data_field"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> 

I can get option elements via js

 select_prod.querySelectorAll('select>option'); 

But the question is how to remove them later? The cycle does not quite fit because when selecting the previous select, additional options are loaded here.

  • one
    document.getElementById("select").innerHTML = ""; - Igor
  • pardon me, all elements In select e (option) - ddeadlink
  • one
    the loop fits, you simply select all the option elements on the page, and not just from a specific select - Grundy

2 answers 2

 var select = document.getElementById('select'); var count = 4; //число элемента по счету var option = select.childNodes[count * 2]; var option2 = select.childNodes[count * 2 - 1]; option.remove(); option2.remove(); 
  • Well and what is it? And for what? - Qwertiy
 document.getElementById('select').innerHTML = "";