jQuery: Finding duplicate ID's and removing all but the first

前端 未结 8 1596
天涯浪人
天涯浪人 2020-12-13 20:57
    $(\'[id]\').each(function () {

        var ids = $(\'[id=\"\' + this.id + \'\"]\');

        // remove duplicate IDs
        if (ids.length > 1 && id         


        
8条回答
  •  孤街浪徒
    2020-12-13 21:36

    Try Using The below function Works fine for me:

     $('#favourities-ajax ul li').each(function(i) {
          $('[id="' + this.id + '"]').slice(1).remove();
          });
    

提交回复
热议问题