Skip to content Skip to sidebar Skip to footer

Jquery Empty() Callback Not Being Fired

I'm emptying an element of all children, then applying an element with the same class but within separate element. The callback on this empty() function isn't firing. Am I missing

Solution 1:

just call the empty function without any parameter and then do whatever you like.

$('.commentsBox').empty();
$('.commentsBox').each(function(){
      $(this).closest('.box').find('.commentsBox').load('url.com');
      $(this).closest('.box').addClass(openComments);
});

Solution 2:

$('.commentsButton').on('click', function(e){
    e.preventDefault();

    $('.box').removeClass('openComments');
    $('.commentsBox').empty();
    $(this).closest('.box').addClass('openComments')
           .find('.commentsBox').load('url.com');
});

Post a Comment for "Jquery Empty() Callback Not Being Fired"