javascript - Adding a button dynamically with JQuery without using .append -
i've got scenario in want button appear, scenario looped over.
my code @ moment looks like:
var r = $('<input type="button" value="done swapping"/>'); $('#doneswapping').append(r); i want button appear once, due using .append keeps getting added during each iteration, resulting in several buttons.
is there way around this? maybe removing button again @ end of loop? did try .remove seems remove entire 'doneswapping' reference rather button.
thank :)
you need use .empty() not destroy structure content in side it.
$('#doneswapping').empty(); .remove() destroy container.
Comments
Post a Comment