tuyenle tuyenle - 2 months ago 16
Javascript Question

how to retrieve appendTo() in DOM

I appended a cloned element $canvas in DOM to the body using this code

$('.' + $canvas).clone().appendTo('body');


but I need to retrieve it to use it like this

$('ul,.map').mousemove(function (e) {
$('.' + $canvas).offset({
left: e.pageX, top: e.pageY
})
});


How do I retrieve a clone $canvas in the DOM?

Answer

Try this

$('body').last('.'+$canvas)

However, you're going to run into issues the second time you do your clone, since it will return two elements

Comments