-1
有没有方法只使用jQuery将外部html文件的预定部分加载到div中?将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);
}
});
});