0

I want to run a script only when a specific div element is loaded. Since the website is using ajax, that specific div does load at default when the page loads. The div will load only later when a specific task is done.

I have tried the code below but can't make it work. How to do that?

jQuery( function($){

    $(".div_class_here").on("load", function() {

    // my code goes here

});

vrec
  • 51
  • 7

1 Answers1

1

you can run after of load the div with ajax

Example:

jQuery( function($){
    $.ajax({
      method: "GET",
      url: "url",//url get data div
      data: { param: "param"}
    })
      .done(function( result ) {
         $(".div_class_here").html(result);
         // my code goes here
         //run you script here
      })
      .fail(function() {
        alert("error");
      });
})
jcHernande2
  • 301
  • 2
  • 6