我将 AJAX 选项卡与 Jquery UI 库一起使用。我需要根据页面更改默认选项卡。我做了很多搜索并尝试了很多。不幸的是,我没有看到任何在 Ajax 选项卡上实现的示例。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<link rel="stylesheet" href="uistyle.css" />
<script>
$(function() {
$( "#tabs" ).tabs()({
active: 2,
beforeLoad: function( event, ui ) {
ui.jqXHR.error(function() {
ui.panel.html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo." );
});
}
});
});
</script>
</head>
<body>
<div id="tabs">
<ul>
<li><a href="#">Tab 1</a></li>
<li><a href="#">Tab 2</a></li>
<li><a href="#">Tab3</a></li>
</ul>
</div>
</body>
</html>