So, I have two js functions:
First js appends a new div container. Second js does something to this new div:
Example:
my_html = '<div class="second"></div>'
jQuery('.first').html(my_html);
jQuery('.second').html("Yay");
Here is the issue. The second js function relies on the existence of class "second".
However, both are run even before the my_html is populated, so I never get "yay" as the result.
Is there a way to somehow delay till the first function is completed? (meaning there is the second div).
EDIT:
Here is the code (please assume that all the code works)
 var THIS_FUNCTION= function (data) {           
    MY_VAR.push("some data");
    alert("before: " + MY_VAR);
 };
 if (//Some condition met) {            
    alert("first function");
    SOME_FUNCTION(THIS_FUNCTION);           
 }; 
 alert("After: " + MY_VAR); 
This is the sequence of alerts that I get:
Alert 1: "first function"
Alert 2: "After:"
Alert 3: "before: some data"
The "before" alert should come in first but I am getting it last.
What am I doing wrong?
 
     
    