I have a selectlist box in Jquery I am doing something like:
$("#Deg").append(degtems);
As I am calling the above code a number of times, it keeps on appending. How do I trunctate and then append.
Thank
Call .empty()
first:
$("#Deg").empty().append(degtems);
..or you could simply use .html()
as @KevinB points out below:
$("#Deg").html(degtems);
Try using .html:
$("#Deg").html(degtems);
It's essentially just doing this:
$("#Deg").empty().append(degtems);
Use the .empty
method on the select element first to remove all children:
$("#Deg").empty()
....
$("#Deg").append(degtems);
.html()
which calls.empty()
and.append()
for the same effect - Kevin B 2012-04-03 19:56