I have two div elements inside another. From time to time, from user interactivity, these two elements are removed and two new elements are placed.
Is it right to delete existing items first? Or just rewrite 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 less code, but should the item be deleted instead? The subjects have no listeners, but if they did, does it matter?
I am an ActionScript developer immersed in JS and jQuery. In AS, if there are any listeners, you must first remove the element in order to break any communication with the object, for the correct memory collection. Are these rules the same with JS and jQuery?
Thank!
source
share