I have two div elements inside another. At times, from user interactivity, these two items are removed, and two new elements are placed.
Is it proper to remove the existing elements first? Or just overwrite the html? Or does it even matter?
$('#item1').remove();
$('#item2').remove();
$('#itemWindow').append(newItem1);
$('#itemWindow').append(newItem2);
Or simply
$('#itemWindow').html(newItem1);
$('#itemWindow').append(newItem2);
One is less code, but should the item be removed instead? The items do not have any listeners, but if they did does that make a difference?
I'm an ActionScript developer diving into JS and jQuery. In AS, if any listeners exist, it's proper to remove the item first to sever any ties to the object, for proper memory collection. Are these rules the same with JS and jQuery?
Thanks!