更新时间:2023-11-03 16:45:46
使用 jQuery.load
方法.
.load( url [, data ] [, complete ] )
当调用元素的addClass
方法时,DOM
中不存在element
,当指定的element
中的external
文件为loaded
时,调用callback
函数.
When you are invoking addClass
method for element, element
does not exist in DOM
, callback
function is invoked when external
file is loaded
in specified element
$(function() {
$("#header").load("page-component/header.html", function() {
jQuery('#menu-about').addClass('active');
});
$("#footer").load("page-component/footer.html", function() {
jQuery('#menu-about').addClass('active');
});
});