Search code examples
javascriptjqueryclone

problem with clone() - events


i have this code:

What reason the new cloned div is not associated to:

        $("#one2 .area").change(function(){  
            alert('changedTwo');  
        });  

i dynamically generate a new id. The first cloned object is: div id="one2"

How i can fix that? thanks!


Solution

  • It might be that the element didn't exist when the event-handlers were bound, on document ready. To test, you could change to:

    $("#one2 .area").live('change', function(){  
            alert('changedTwo');  
        });
    

    Reference: