一个Degradable jQuery UI Tabs 滑动门代码
Creating tabbed content is easy with jQuery UI. Using a simple HTML layout and calling the tabs function is all it takes. Here, I'll show you how to make a degradable tabbed interface. That is, we'll make it so the page is still readable when JavaScript is disabled. This involves hiding and showing elements using JavaScript before enabling tabs.
See the live demo. Try turning off JavaScript to see how it degrades.
Here is the HTML of the tab widget. By default, UI tabs use an unordered list with anchor links as the tabs and corresponding div tags with the content. The list starts hidden and will be shown with JavaScript, and each section has a heading that we will hide if JavaScript is enabled.
<ul class="tabmenu hidden">
<li><a href="#tab-1">Tab 1</a></li>
<li><a href="#tab-2">Tab 2</a></li>
<li><a href="#tab-3">Tab 3</a></li>
<li><a href="#tab-4">Tab 4</a></li>
</ul>
<div id="tab-1">
<h2>Tab 1</h2>
<p>Content of tab 1</p>
</div>
<div id="tab-2">
<h2>Tab 2</h2>
<p>Content of tab 2</p>
</div>
<div id="tab-3">
<h2>Tab 3</h2>
<p>Content of tab 3</p>
</div>
<div id="tab-4">
<h2>Tab 4</h2>
<p>Content of tab 4</p>
</div>
</div>
只需要一个Class:
display: none;
}
JavaScript.代码:
$(".tabmenu").removeClass("hidden");
$(".tabs h2").addClass("hidden");
$(".tabs").tabs();
});
完整的HTML代码:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.hidden {
display: none;
}
</style>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function() {
$(".tabmenu").removeClass("hidden");
$(".tabs h2").addClass("hidden");
$(".tabs").tabs();
});
</script>
<title>Degradable jQuery UI Tabs</title>
</head>
<body>
<h1>Degradable jQuery UI Tabs</h1>
<div class="tabs">
<ul class="tabmenu hidden">
<li><a href="#tab-1">Tab 1</a></li>
<li><a href="#tab-2">Tab 2</a></li>
<li><a href="#tab-3">Tab 3</a></li>
<li><a href="#tab-4">Tab 4</a></li>
</ul>
<div id="tab-1">
<h2>Tab 1</h2>
<p>Content of tab 1</p>
</div>
<div id="tab-2">
<h2>Tab 2</h2>
<p>Content of tab 2</p>
</div>
<div id="tab-3">
<h2>Tab 3</h2>
<p>Content of tab 3</p>
</div>
<div id="tab-4">
<h2>Tab 4</h2>
<p>Content of tab 4</p>
</div>
</div>
</body>
</html>
转自:http://www.ultramegatech.com/blog/2009/09/degradable-tabs-with-jquery-ui/
- Reads(2215)
- Comments(0)

Sugarhosts主机终身七折优惠
30个极具创意的JavaScript导航菜单实例