ranjutk ranjutk - 11 months ago 52
jQuery Question

How to clone back a pop up which is already cloned from an underlying div

I have a dynamic page which get the dat from api. Each div has picture and click button with counter.Consider a pop up div which is just a zoomed version of the normal div. I used bootstrap modal class to make the zoom in with .clone(true) in jquery. As I have a click functionality with counter in the original div and pop up, I want the value of the counter to return back to the underlying div.
Example. If somebody click my counter and value is updated, the value is reflected in the pop up. But if somebody is clicked in the pop up the value is not carried back to the original or underlying div. How to do it?

This is the jquery code.

var post_popover = function(){
var include = $(this).parent().parent().clone(true);
$(include).find('#displaysquare').css("display", "none");
$(include).find("#zoom").css("display", "block");
return false;

$("div#lazy").on('click', post_popover);
$("video#vlazy").on('click', post_popover);

if(e.keyCode==27){//esc key
$("#lazy").load(location.href + " #lazy");


you can set the content of a div with $("#myDiv").html("anything");. So just handle the click event of the popup and update the value. If you need to trigger the ajax event to update the count within that then do so. From your code it looks like you already know how to bind a click event and presumably you know how to make an ajax call...so it should be fairly straightforward.