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')
;

Leave a Comment