.tab('show')不起作用

wangch_sk 发布于 2013/12/06 16:44
阅读 688
收藏 0

问题:测试bootstrap的"Navs"样式时,点击导航栏没反应,是还需引入什么js吗,感觉像是.tab('show')方法没执行,请教了

浏览器:chrome

代码:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'helloworld.jsp' starting page</title>
	<link href="<%=path %>/Resources/css/bootstrap.css" rel="stylesheet">
    <script src="<%=path %>/Resources/js/jquery-1.6.4.js"></script>
    <script src="<%=path %>/Resources/js/bootstrap.js"></script> 
  </head>
  <body>
	<ul class="nav nav-tabs" id="myTab">
	  <li class="active"><a href="#home" data-toggle="tab">Home</a></li>
	  <li><a href="#profile" data-toggle="tab">Profile</a></li>
	  <li><a href="#messages" data-toggle="tab">Messages</a></li>
	  <li><a href="#settings" data-toggle="tab">Settings</a></li>
	</ul>
	
	<div class="tab-content">
	  <div class="tab-pane active" id="home">sdfsdfs</div>
	  <div class="tab-pane" id="profile">...</div>
	  <div class="tab-pane" id="messages">...</div>
	  <div class="tab-pane" id="settings">aaa</div>
	</div>

	<script>
		$('#myTab a').click(function (e) {
			e.preventDefault();//阻止a链接的跳转行为  
		  	$(this).tab('show')
		})
	</script>
  </body>
</html>




加载中
0
张鹏阳
张鹏阳

tab('show')使用之前需要先初始化面板  你这种情况模拟两次点击事件可以jie'jue

返回顶部
顶部