每次我单击按钮时,我都希望获得所选选项卡的索引,而不是我得到 null
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>jQuery UI Tabs Example 1</title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js'></script>
<script>
$(function() {
$("#tabs").tabs();
$("#button").click(function() {
var current_index = $("#tabs").tabs("option","selected");
alert("The index of the current tab is " + current_index);
});
});
</script>
</head>
<body>
<button id="button">Click me</button>
<div id="tabs">
<ul>
<li><a href="/buildFirstTab">First Tab</a></li>
<li><a href="/buildSecondTab">Second Tab</a></li>
<li><a href="/buildThirdTab">Third Tab</a></li>
</ul>
</div>
</body>
</html>