Answers for "js remove all options from select"

4

remove all options from select jquery

$('#mySelect')
    .empty()
Posted by: Guest on March-18-2020
2

How to remove options from selectlist in javascript?

var selectobject = document.getElementById("mySelect");
for (var i=0; i<selectobject.length; i++) {
    if (selectobject.options[i].value == 'A')
        selectobject.remove(i);
}
Posted by: Guest on May-03-2020
1

js clear all select options

for (var option of document.querySelectorAll('#DropList option'))
{ 
  option.remove();
}
Posted by: Guest on February-25-2022
0

How to remove options from selectlist in javascript?

<select id="mySelect" name="val" size="1" >
    <option value="A">Apple</option>
    <option value="C">Cars</option>
    <option value="H">Honda</option>
    <option value="F">Fiat</option>
    <option value="I">Indigo</option>                    
</select>
Posted by: Guest on May-03-2020

Code answers related to "js remove all options from select"

Code answers related to "Javascript"

Browse Popular Code Answers by Language