fSelect Clear Selection

后端 未结 2 831
日久生厌
日久生厌 2021-01-03 13:38

How to clear fSelect multi-select drop-down in click event, Here is an example By Clicking on Clear button It should remove all Selected value.

2条回答
  •  北海茫月
    2021-01-03 14:23

    You could clear by looping through the option and unselect them like :

    $(function() {
      $('.my-select-box').fSelect();
    
      $('#ClearSelect').click(function() {
        $('#fselectMulti option:selected').removeAttr('selected');
    
        $('.my-select-box').prev(".fs-dropdown").find(".fs-options .fs-option").each(function() {
          $(this).removeClass('selected', false);
        });
    
        console.log($('#fselectMulti').val());
        $('.fs-label').html('Select some options');
      })
      $('#CheckSelect').click(function(){
        console.log($('#fselectMulti').val());
      })
    });
    
    
    
    
    
    
    

提交回复
热议问题