我希望topic.html加载(点击我的href时)代替div
#courseDiv
。我怎样才能做到这一点?我知道你必须使用Jquery.load
但是如何使用?
JS:
$(document).ready(function(){
$('#topics').click(function(){
$('#contain').load('topics.html');
});
HTML:
<div id = "courseDiv">
<h1 class = "courseOptions" id = "choosetitle">Choose a title</h1>
<h1 class = "courseOptions">Age group</h1>
<h1 class = "courseOptions">What will you learn?</h1>
</div>
我的href:
<div id = "courseNavDiv">
<ul class = "nav nav-list nav-stacked breadcrumbs col-md-2 col-lg-2" id = "courseNav">
<li class = "disabled" id = "title"><a href="#">Title</a></li>
<li id = "topics"><a href="#">Topic</a></li>
<li><a href="#">Topic</a></li>
<li><a href="#">Topic</a></li>
</ul>
</div>
答案 0 :(得分:1)
将$('#contain')
更改为$('#courseDiv')
并添加缺少的括号});
$(document).ready(function(){
$("#topics").click(function(){
$("#courseDiv").load("topics.html");
});
});
答案 1 :(得分:0)
我猜您错过了代码中的});
...
$(document).ready(function(){
$("#topics").click(function(){
$("#contain").load("topics.html");
});
});