我目前无法在添加新元素之前清除容器div. (当空()时,整个div被擦干净,我不想要这个.我只想删除现有的书架元素.有什么我做错了吗?和/或可能因为“文本/模板“脚本?)
JQUERY片段
$.get( "URL",function(data) {
var entry = $(data).find("entry");
entry.each(function() {
var template = $("#template").html();
//$("#Maincontainer").remove(); - >clear whole div,appended elements not show
//$("#Maincontainer").remove("#bookHolder"); -> Div not cleared
$("#Maincontainer").append(template.replace("{{bookName}}",bookName).replace("{{summary}}",summary).replace("{{price}}",price).replace("{{seller}}",artist).replace("{{imgURL}}",image)
.replace("{{href}}",href).replace("{{category}}",category));
});
});