此代码调用新数据并将其放入 div 中,但不会替换旧的 htm。它只是增加了它。代码中有错误,但我找不到它们。如何让它替换 htm 文件而不仅仅是添加到数据中?
.click(function () {
$('.tabActive').removeClass('tabActive');
$(this).addClass('tabActive');
var lesson = $(this).attr('.lesson');
var self = this
$("#loading").show();
setTimeout(function () {
$.ajax({
type: "GET",
url: 'lessons/' + lesson + '.htm',
datatype: "html",
success: function (data) {
$('#sectionTabContent').append(data);
},
complete: function () {
$("#loading").hide();
}
})
}, 3000);
});
}
HTML
<div id='sectionThreeTabs'>
<div id='' class='sectionThreeTab tabActive' lesson='first'>
Try
</div>
<div class='sectionThreeTab' lesson='second'>
Anger
</div>
<div class='sectionThreeTab' lesson='third'>
Size
</div>
</div>