The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Remove dynamically appended elements

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #42387

    I have a problem with my JS code:

    I want to achieve that every element with the class .activity is removed. What I do is:

    $(".activity").each(function() {

    Basically this works fine the first time. But as the one .activity is removed, I append a new one. And the .remove() function does not work there.

    I saw that there is a method .live() (.on()), but this takes an event like a click. I have no event; I just want to select every appended element and remove it then.


    I do an ajax request loading new data. With this data there come new activities. So i want to remove the old ones and add the new ones.

    I hope this is clearer now :)

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.