Imagine I have the following code:
...
<div id="div1">
<div id="div2">Original div2</div>
</div>
<div id="div3"></div>
...
if I run
$('#div1').html('');
$('#div3').html('<div id="div2">New div2</div>');
do I end up with problems because I didn't use .remove() to remove #div2 from the dom, or does clearing the html in this way do that for me?
What if div2 contained some javascript that attached a handler, say something like
$('#div2').on('click',function() { ... });
would that also be removed, or would I need to off() it?