This is pretty much the same problem as in here: Click event doesn't work on dynamically generated elements , but that post was a few years old, and it's solution did not work for me.
I have a small image carousel, which works properly when I add it directly to html, but when I add it dynamically the jQuery click event for buttons does not work. I tried changing from button.click() to button.on("click,function(){}) but it still doesn't work. Can someone tell me 
a) How to make it work
b) How does modyfying DOM affects jQuery execution, so I understand it better in the future (for example, are there some DOM element jquery ignores?)
my code:
$(document).ready(function(){
    $(".carousel-button-left").on('click',function(){
    var $ul=$(this).next().find(".carouselUl");;
    //alert(""+$ul.html());
    var $lastchild=$ul.children().last();
    $ul.prepend($lastchild);
    });
});
$(document).ready(function(){
    $(".carousel-button-right").on("click",function(){
    var $ul=$(this).prev().find(".carouselUl");
    //alert(""+$ul.html());
    var $firstchild=$ul.children().first();
    $ul.append($firstchild);
    });
});
 
     
     
     
    