4款jQuery实用的响应式选项卡tab切换代码



185 737 246



特效描述:jQuery 实用响应式选项卡 选项卡tab切换,四种酷炫的tab切换代码,jQuery响应式选项卡切换。

代码结构

1. 引入CSS

<link rel="stylesheet" type="text/css" href="css/demo.css">
<link rel="stylesheet" href="assets/css/tabs/tabs-basic.css">

2. 引入JS

<script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>

3. HTML代码

	<header class="htmleaf-header">
		<div class="htmleaf-demo center">
		  <a href="index.html" class="current">基本</a>
		  <a href="index2.html">彩色</a>
		  <a href="index3.html">下划线</a>
		  <a href="index4.html">垂直</a>
		</div>
	</header>
	<div class="tabs-basic">
		<ul>
			<li>
				<a class="tab-active" data-index="0" href="#">First tab</a>
			</li>
			<li>
				<a data-index="1" href="#">Second tab</a>
			</li>
			<li>
				<a data-index="2" href="#">Third tab</a>
			</li>
		</ul>
		<div class="tabs-content-placeholder">
			<div class="tab-content-active">
				<p>Lorem ipsum dolor ist amet, consectetur adipiscing elit. Suspendisse molestie volutpat consectetur. Class aptent taciti sociosqu ad litora torquent per conubia nostra.</p>
				<img src="assets/images/pictures/bahnhoff.jpg" alt="Banhoff">
			</div>
			<div>
				<p>Lorem ipsum dolor ist amet, consectetur adipiscing elit. Suspendisse molestie volutpat consectetur. Class aptent taciti sociosqu ad litora torquent per conubia nostra.</p>
				<img src="assets/images/pictures/colosseum.jpg" alt="Colosseum">
			</div>
			<div>
				<p>Lorem ipsum dolor ist amet, consectetur adipiscing elit. Suspendisse molestie volutpat consectetur. Class aptent taciti sociosqu ad litora torquent per conubia nostra.</p>
				<img src="assets/images/pictures/sands-of-life.jpg" alt="Sands of Life">
			</div>
		</div>
	</div>
	<script type="text/javascript">
        $(document).ready(function() {
            var widget = $('.tabs-basic');
            var tabs = widget.find('ul a'),
                content = widget.find('.tabs-content-placeholder > div');
            tabs.on('click', function (e) {
                e.preventDefault();
                // Get the data-index attribute, and show the matching content div
                var index = $(this).data('index');
                tabs.removeClass('tab-active');
                content.removeClass('tab-content-active');
                $(this).addClass('tab-active');
                content.eq(index).addClass('tab-content-active');
            });
        });
    </script>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 滚动切换 滚动条切换 滑动选项卡 滑动切换 选项卡切换 选项卡 切换 tab切换 页面切换 选项卡插件 切换插件 滑动手风琴 选项卡自动切换

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到