im trying to replace various elements with another inside a jquery .each loop and give them on click events to their child nodes, but it does not work, here is my code.
var replacer = function () {
  var elementbody = "<div class='Container'><div class='Button'></div></div>";
  $('.myclass').each(function (index, element) {
    $(element).replaceWith(elementBody);
    $(element).find('.Button').click(function () {
  //------------------To do on click event------------------//
});
};
 
     
    