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( "<开发者_JAVA百科;span>foobar</span>" )
    }
  } )
);
In the above example I use .load() as pseudo-code to do what I want -- It doesn't work for me. Here, .load() executes the function and sets $(this) to the element I attached the event too.
It sounds like maybe you just need to back some of your code out of the append(). Right now, the argument sent to append() isn't valid.
Based on your example, I guess I'm just not sure why you don't do something like this:
var $foo = $('#foo');
if( $foo.find('.foo').length ) {
    $foo.append("<span>foobar</span>");
}
Please provide more info if this doesn't meet your need.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论