Jquery - dynamic DIV onclick binding
- by Murtaza RC
I have a main page from where I am making a call to "load" and intermediate page's HTML and on the completion of the load I am massaging the returned HTML to add a few DIVs etc, when I try to bind an onclick event for the dynamic Divs (added by me after the HTML returned from the intermediate page) it does not seem to work at all !:
LOAD :
$j(".loader").load(myURLtoIntermediatePage, '', function() {
var HTML= '<div id="abcd">test</div>';
...
$j(".pageDIV").append(HTML);
}
DOCUMENT READY Function
$j(document).ready(function() {
$j('#abcd').onclick(function() {
alert($j(this));
});
});