This question has already been answered:
There is a block:
<div class="block"> </div> When clicking on this block, other blocks are inserted into it:
for (i=0; i<n; i++) { $(".block").append("<div class='inner'></div>"); } <div class="block"> <div class="inner"></div> <div class="inner"></div> <div class="inner"></div> <div class="inner"></div> </div> How to perform a function by clicking on an element with a class. .inner ? Running a script on a click only works if the code immediately contains blocks with the class .inner , but if they are inserted via .append , then the script is no longer running.
$(".inner").click(function(){ alert("Клик"); }