JQuery - dynamic onclick div snapping

I have a main page where I call the “download” and the HTML intermediate page, and when the download is complete, I massage the returned HTML to add a few DIVs, etc., when I try to link the onclick event for dynamic Divs (added by me after returning HTML from an intermediate page), it looks like it doesn't work at all !:

LOAD:

$j(".loader").load(myURLtoIntermediatePage, '', function() {
     var HTML= '<div id="abcd">test</div>';
     ...

     $j(".pageDIV").append(HTML);    
}

DOCUMENTS READY Function

$j(document).ready(function() {

 $j('#abcd').onclick(function() {
            alert($j(this));
        });

});
+3
source share
1 answer

This requires jQuery 1.3:

$j("#abcd").live("click", function() {
    alert($j(this));
});
+7
source

Source: https://habr.com/ru/post/1716417/


All Articles