Quantcast
Viewing all articles
Browse latest Browse all 43

Answer by HMR for How to move an element into another element

I need to move content from one container to another including all the event listeners. jQuery doesn't have a way to do it, but the standard DOM function appendChild does.

// Assuming only one .source and one .target$('.source').on('click',function(){console.log('I am clicked');});$('.target')[0].appendChild($('.source')[0]);

Using appendChild removes the .source* and places it into target including its event listeners: Node.appendChild() (MDN)


Viewing all articles
Browse latest Browse all 43

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>