Search code examples
javascriptjqueryfadeinjquery-after

jQuery fadeIn() following after()


I was looking to do a .fadeIn() animation chained to this .after(), but this doesn't appear to be the way of doing it. Any suggestions?

$(clicked_item).parent().parent().parent().after(str).fadeIn("slow");

Solution

  • You should use .insertAfter();

    $(str)
      .hide()
      .insertAfter($(clicked_item).parent().parent().parent())
      .fadeIn("slow");