0

So I need to remove links that id matches the id in array. Heres the code:

   for(let i = 0; i < allyList.length; i++) {
    if ( $.inArray(allyList[i], allyArray) > -1 ) {
        // In this if statement I'm checking if id's from allyList matches id's allyArray
    }
   }

This code ^ above works fine. It checks if ID's matches. But now I have this link:

<a href="/join-alliance/{{this.title}}" id="{{this._id}}" class="btn btn-success join">Join</a>

These links id is all the same as allyList id's. I need to somehow get these links in array and then check in that if statement above if the links id's matches the ones in allyList. And if the id matches I need to remove that link.

4

1 回答 1

0

如果我理解正确,那么在需要从 dom 中删除的 allyArray 中具有 id 的链接。

 $(".join").each(function() {
       if(allyArray.indexOf($(this).attr("id")) > -1)
          $(this).remove();
  });
于 2018-12-05T09:41:59.533 回答