Jquery - dynamic DIV onclick binding
        Posted  
        
            by Murtaza RC
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Murtaza RC
        
        
        
        Published on 2009-08-30T07:26:18Z
        Indexed on 
            2010/04/07
            5:23 UTC
        
        
        Read the original article
        Hit count: 427
        
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));
        });
});
© Stack Overflow or respective owner