How to make the first option of <select> selected with jQuery How to make the first option of <select> selected with jQuery jquery jquery

How to make the first option of <select> selected with jQuery


$("#target").val($("#target option:first").val());


You can try this

$("#target").prop("selectedIndex", 0);


// remove "selected" from any options that might already be selected$('#target option[selected="selected"]').each(    function() {        $(this).removeAttr('selected');    });// mark the first option as selected$("#target option:first").attr('selected','selected');