0

After I've used .insertBefore to place div the page, the div doesn't appear to be recognized as jQuery("#temp").

Is there something special I need to do to get it to be active and receive onClick actions?

jQuery( document ).ready(function() {

    var temp_text = '<div id="temp">temp</div>';

    if ( jQuery.temp("temp") )
        console.log( 'FOUND temp' );
    else
        jQuery( temp_text ).insertBefore( "#top-bar" );

});

jQuery("#temp").on("click", function () {
    console.log('clicked');
});
Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75

0 Answers0