下面是我的代码的链接,它在 Fiddle 中运行良好
小提琴链接:http: //jsfiddle.net/JdU8N/
但是相同的代码在我的本地不起作用。我已经正确加载了 jQuery 文件并在$(document).ready(function(){});
. 使用萤火虫,我也没有收到任何错误
这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$('.tabs').tabs();
$('.subtabs').tabs({
activate: function(event, ui) {
//get relative li index
var secondTabSelected = $(ui.newTab).index();
console.log(secondTabSelected);
}
});
});
</script>
</head>
<body>
<div class="tabs">
<ul>
<li><a href="#tabs-1">Tab 1</a></li>
<li><a href="#tabs-2">Tab 2</a></li>
</ul>
<div id="tabs-1">
<div class="subtabs">
<ul>
<li><a href="#tabs-1a">Tab 1-A</a></li>
<li><a href="#tabs-1b">Tab 1-B</a></li>
</ul>
<div id="tabs-1a">
<p>Tab 1A</p>
</div>
<div id="tabs-1b">
<p>Tab 1B</p>
</div>
</div>
</div>
<div id="tabs-2">
<div class="subtabs">
<ul>
<li><a href="#tabs-2a">Tab 2-A</a></li>
<li><a href="#tabs-2b">Tab 2-B</a></li>
</ul>
<div id="tabs-2a">
<p>Tab 2A</p>
</div>
<div id="tabs-2b">
<p>Tab 2B</p>
</div>
</div>
</div>
</div>
</body>
</html>
任何帮助,将不胜感激 ...