这似乎很容易,但我有点卡住了。 我有两页: 第1页
<!doctype html>
<html class="">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled Document</title>
<link href="boilerplate.css" rel="stylesheet" type="text/css">
<link href="guitar.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="respond.min.js"></script>
</head>
<body>
<div class="gridContainer clearfix">
<div id="Header"></div>
<script type="text/javascript">
function check() {
$('#Header').load('ajax/header.html #main_header');
}
</script>
</div>
</body>
</html>
第2页
<body>
<div class="gridContainer clearfix">
<div id="main_header">
<div id="Logo">
<img src="files/images/LogoAMKGuitars.png" alt="AMKGuitars">
</div>
<div id="Search_Bar">
<form action="search.php" method="post" id="search"name="search">
<input id="search_field" name="search_field" type="text" placeholder="Search product">
<input id="search_submit" name="search_submit">
</form>
</div>
<div id="Basket">
<img src="files/images/viewbasket.png" alt="View Basket">
</div>
<div id="Phone">Tel: 0116-2541053</div>
</div>
</div>
</body>
我想将div id="main_header
的内容放入第二页的Header div中。欢迎任何帮助。
答案 0 :(得分:2)
好像你没有在任何地方调用check()函数,如下所示:
<script type="text/javascript">
function check(){
$('#Header').load('ajax/header.html #main_header');
}
$(function() {
check();
});
</script>