How do you remove all the options of a select box and then add one option and select it with jQuery? How do you remove all the options of a select box and then add one option and select it with jQuery? javascript javascript

How do you remove all the options of a select box and then add one option and select it with jQuery?


$('#mySelect')    .find('option')    .remove()    .end()    .append('<option value="whatever">text</option>')    .val('whatever');


$('#mySelect')    .empty()    .append('<option selected="selected" value="whatever">text</option>');


why not just use plain javascript?

document.getElementById("selectID").options.length = 0;