如何使用jQuery用JSP代码替换div内容?
我尝试了以下代码,但它没有显示任何内容。
HTML:
(ie. GetProfiles(oauth_token)
tableid_input = "ga:72848696")
jQuery的:
<ul class="list-group" id="menuList">
<li id="dashboard" class="list-group-item active">
<span class="glyphicon glyphicon-home"> </span>
Dashboard
</li>
<li id="users" class="list-group-item">
<span class="glyphicon glyphicon-user"> </span>
Users
<span class="badge">5</span>
</li>
<li class="list-group-item">
<span class="glyphicon glyphicon-tasks"> </span>
Tasks
<span class="badge">0</span></li>
<li class="list-group-item">
<span class="glyphicon glyphicon-th-list"> </span>
Articles
<span class="badge">0</span>
</li>
<li class="list-group-item">
<span class="glyphicon glyphicon-cog"> </span>
Settings
</li></ul>
<div class="col-md-10 col-centered" id="content"></div>
答案 0 :(得分:0)
试试这个:你没有正确关闭括号。
<ul class="list-group" id="menuList">
<li id="dashboard" class="list-group-item active"> <span class="glyphicon glyphicon-home"> </span>Dashboard</li>
<li id="users" class="list-group-item"> <span class="glyphicon glyphicon-user"> </span>Users<span class="badge">5</span></li>
<li class="list-group-item"> <span class="glyphicon glyphicon-tasks"> </span>Tasks<span class="badge">0</span></li>
<li class="list-group-item"> <span class="glyphicon glyphicon-th-list"> </span>Articles<span class="badge">0</span></li>
<li class="list-group-item"> <span class="glyphicon glyphicon-cog"> </span>Settings</li></ul>
<div class="col-md-10 col-centered" id="content"></div>
<script>
$(document).ready(function(){
$("#menuList > li").click(function(){
$(this).siblings().removeClass("active");
$(this).addClass(" active");
var id = $(this).attr('id');
$("#content").html("<jsp:include page='users.jsp' />");
});
});
</script>