I bind a dropdown in mvc application with “– select year –” as a First element, On selection a item from dropdown I want to delete “– select year –” item from the drop down. How to achieve this?
Below code delete all items from dropdown…what need to make change here,
<script type="text/javascript">
$(document).ready(function () {
$('#Year').change(function () {
var yearsSelect = $('#Year');
debugger;
yearsSelect.empty();
});
});
</script>
or if you want to remove the one with an empty value (which is what the
DropDownListForhelper uses for the default value):