jQuery: How do I make a manipulation dependant on the DOM prior to insertion, relative to the insert

Posted by Evan Carroll on Stack Overflow See other posts from Stack Overflow or by Evan Carroll
Published on 2010-06-02T19:01:55Z Indexed on 2010/06/02 19:04 UTC
Read the original article Hit count: 207

Filed under:

I want to make it so that I .append() to a value based on the status of some other element relative to the place I'm inserting into the dom. What I really want is a trigger that fires after the element has been inserted.

$("#foo").append(
  $('<div />').load( function () {
    if ( $(this).find('.foo') {
      $(this).append( "<span>foobar</span>" )
    }
  } )
);

© Stack Overflow or respective owner

Related posts about jQuery