I've read that if you add new elements to the document, or if you modify the already existing elements and you want to asign a behaviour to them via jQuery, you would have to bind the new elements with the existing behaviour pattern.
Could anyone explain to me why this is not working: $(document).ready(function() { $("#menu a").click(function(e){ $.post("jquery.php", {Option: $(this).html()}, function(xml) { $("#content").html("<h1>"+$("txt", xml).text() +"</h1><p>"+ $ ("aaa",xml).text() +"</p><h1>"+ $("txt", xml).text() +"</h1><p>" + $ ("bbb",xml).text() + "</p>");}); $('#content p').hide(); $('#content h1').click(function() { $(this).next().slideToggle(); }); }); $('#content p').hide(); $('#content h1').click(function() { $(this).next().slideToggle(); }); }); The "original" click/toogle data from #content div works just fine, but once i change the contents of #content via AJAX, click/toogle doesn't work at all. Thank you very much.