Add again after remove

dom, jquery

Solution

Remove is not a property, the element is actually gone. To just hide it temporarly use hide() and show(), to detach it an reattach it later use detach().

var elm = $("#elementID").detach();

$(button).on('click', function() {
    elm.appendTo('#popupID');
});

Problem

I removed an element with `remove()` as I said before in : Removing higher layer now when I click again on my link to open popup, the link cannot work because that layer removed before. How can I remove the remove property from my element ? UPDATE: I use `requireJS` plugin to load a JS file when click on link : ``` $('a#addUser').click(function () { require (['controllers/users/add'],function() { $('#loading').fadeOut('fast'); }); }); ``` In controllers/users/add.js I have that popup, user can close popup, I don't have any problem up to here, the problem is when user click again on link and popup should be show again, but in my code that popup does not open again. ANSWER: The problem is requreJS, because this plugin allow me to load my javascript just one time, I should use `$.getScript()` instead of requreJS

Original source