有没有办法使用 jQuery 仅将外部 html 文件的预定部分加载到 div 中?
如果外部 html 被细分(例如使用<div id="section1", "...2", "...3">
)成单独的部分,jQuery 是否可以仅捞出 div id="section1" 并将其输出到目标 div 中?
我可以调整这段代码来完成它吗?
$(document).ready(function () {
$.ajax({
url : "sourceFile.html",
dataType : "html",
success : function (data) {
$("#targetDIV").html(data);
},
error : function (XMLHttpRequest, textStatus, errorThrown) {
alert("doc did not load. Status: " + textStatus);
alert("doc did not load. Error: " + errorThrown);
}
});
});