Delete duplicate entries from a select box

前端 未结 4 1589
梦谈多话
梦谈多话 2021-01-05 17:18

How would I, using jQuery, remove the dups

        
        
4条回答
  •  爱一瞬间的悲伤
    2021-01-05 17:57

    From top of my head, untested:

    $('#mySelect option').each(function(){
      if ($('#mySelect option[value="'+$(this).val()+'"]').length) $(this).remove();
    });
    

提交回复
热议问题