I've got a scenario in which I want a button to appear, however this scenario is looped over.
My code at the moment looks like:
var r = $('<input type="button" value="Done swapping"/>');
$('#doneSwapping').append(r);
I only want the button to appear once, but due to using .append it keeps getting added during each iteration, resulting in several buttons.
Is there a way around this? Maybe removing the button again at the end of the loop? I did try .remove but that seems to remove the entire 'doneSwapping' reference rather than just the button.
Thank you :)
you need to use
.empty()
it will not destroy the structure but the content in side it..remove()
will destroy the container.