这个去重不是很好用,如果id值不同,text是一样的,也会被去掉

 

<input type="button" class="btn" id="btn" value="去重" />

jquery:

//去重
$(function(){
    $("#btn").click(function() {
        $("select option").each(function() {
            text = $(this).text();
            if($("select option:contains("+text+")").length > 1)
                $("select option:contains("+text+"):gt(0)").remove();
        });
    });
})

 

相关文章:

  • 2022-03-06
  • 2021-09-11
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2023-04-08
  • 2022-03-03
  • 2021-07-02
相关资源
相似解决方案