How do I clear the dropdownlist values on button click event using jQuery?

后端 未结 4 424
萌比男神i
萌比男神i 2020-12-23 20:29

How do I clear the dropdownlist values on button click event using jQuery?

4条回答
  •  执笔经年
    2020-12-23 20:53

    If you want to reset the selected options

    $('select option:selected').removeAttr('selected');
    

    If you actually want to remove the options (although I don't think you mean this).

    $('select').empty();
    

    Substitute select for the most appropriate selector in your case (this may be by id or by CSS class). Using as is will reset all

    提交评论

提交回复
热议问题