jQuery分页插件使用

jQuery 同时被 2 个专栏收录
10 篇文章 0 订阅
6 篇文章 0 订阅

jquery.tabulation.js插件介绍

jquery.tabulation.js是一款兼容bootstrapjQuery分页插件。该插件可将一组同级元素转换为分页或tabs,提供回调函数,实现可分页功能。

一、jquery.tabulation.js插件使用方法

首先是引入一些基础的资源问价,包括jqueryjquery.tabulation.js文件。

<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery.tabulation.js"></script>

HTML结构:需要一些基本的页面结构,代码如下:

<div class="js-tabulation" data-tabulation-id="first"> <!-- Container -->
  <!-- 内容 -->
  <span data-tabulation-ref="first" data-tabulation-tab="1">Tab with index "1"</span>
  <span data-tabulation-ref="first" data-tabulation-tab="2">Tab with index "2"</span>
  <span data-tabulation-ref="first" data-tabulation-tab="3">Tab with index "3"</span>
 
  <!-- 分页导航 -->
  <span data-tabulation-ref="first" data-tabulation-nav="1">First</span>
  <span data-tabulation-ref="first" data-tabulation-nav="2">Second</span>
  <span data-tabulation-ref="first" data-tabulation-nav="3">Third</span>
</div>

初始化插件:主要是在DOM元素加载完毕之后,通过tabulation()方法来初始化插件。

二、jquery.tabulation.js插件配置参数

jquery.tabulation.js插件有一些必要的参数需要配置,以完成更加丰富的功能

$('.js-tabulation').tabulation({
  default: undefined, // Default tab to enable on startup
  nav: 'active', // Class for navigation if active
  tab: 'active', // Class for tab if active
  beforeSet: undefined, // Function before tab changed. Stops if return false
  afterSet: undefined // Function called after active tab changed
});

上述的参数解释如下:
1.default:默认显示的激活项。
2.nav:分页导航上的激活class类。
3.tab:tab上的激活class类。
4.beforeSet:tab改变前的回调函数。
5.afterSet:tab改变后的回调函数。

三、jquery.tabulation.js插件使用案例:
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>兼容bootstrap的jQuery分页插件jquery.tabulation.js|DEMO_jQuery之家-自由分享jQuery、html5、css3的插件库</title>
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/4.1.1/flatly/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/htmleaf-demo.css"><!--演示页面样式,使用时可以不引用-->
	<style>
		body { background-color: #fafafa; font-family: 'Open Sans'; }
		.container { margin: 150px auto; }
		.tabulation-active-button1 {
			background: black !important;
			color: red !important;
		}
		.tabulation-active-button2 {
			background: red !important;
			color: black !important;
		}
	</style>
</head>
<body>
	<div class="htmleaf-container">
		<header class="htmleaf-header">
			<h1>兼容bootstrap的jQuery分页插件jquery.tabulation.js <span>Bootstrap Compatible Pagination For Tabs - jQuery tabulation.js</span></h1>
			<div class="htmleaf-links">
				<a class="htmleaf-icon icon-htmleaf-home-outline" href="http://www.htmleaf.com/" title="jQuery之家" target="_blank"><span> jQuery之家</span></a>
				<a class="htmleaf-icon icon-htmleaf-arrow-forward-outline" href="http://www.htmleaf.com/jQuery/Layout-Interface/201903215574.html" title="返回下载页" target="_blank"><span> 返回下载页</span></a>
			</div>
		</header>
		<div class="container text-center">
			<h1>jquery.tabulation: Tabs Paginator Demos</h1>
			<div class="row">

				<div class="col-lg-6 mt-5">
					<div class="card" data-tabulation>
						<div class="card-header">
							Init with data attribute (standard)
						</div>
						<div class="card-body">
							<div data-tabulation-tab>Tab #1</div>
							<div data-tabulation-tab>Tab #2</div>
							<div data-tabulation-tab>Tab #3</div>
							<div data-tabulation-tab>Tab #4</div>
							<div data-tabulation-tab>Tab #5</div>
						</div>
						<div class="card-footer">
							<a href="#" class="btn btn-info" data-tabulation-nav="prev">prev</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="1">1</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="2">2</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="3">3</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="4">4</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="5">5</a>
							<a href="#" class="btn btn-info" data-tabulation-nav="next">next</a>
						</div>
					</div>
				</div>

				<div class="col-lg-6 mt-5">
					<div class="card" data-tabulation>
						<div class="card-header">
							Set active tab on init
						</div>
						<div class="card-body">
							<div data-tabulation-tab>Tab #1</div>
							<div data-tabulation-tab>Tab #2</div>
							<div data-tabulation-tab class="active">Tab #3</div>
							<div data-tabulation-tab>Tab #4</div>
							<div data-tabulation-tab>Tab #5</div>
						</div>
						<div class="card-footer">
							<a href="#" class="btn btn-info" data-tabulation-nav="prev">prev</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="1">1</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="2">2</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="3">3</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="4">4</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="5">5</a>
							<a href="#" class="btn btn-info" data-tabulation-nav="next">next</a>
						</div>
					</div>
				</div>

				<div class="col-12 mt-5">
					<div class="card" data-tabulation>
						<div class="card-header">
							Unlimited nav buttons
						</div>
						<div class="card-body">
							<div class="row">
								<div class="col">
									<a href="#" class="btn btn-light" data-tabulation-nav="1">1</a>
									<a href="#" class="btn btn-light" data-tabulation-nav="2">2</a>
									<a href="#" class="btn btn-light" data-tabulation-nav="3">3</a>
								</div>
								<div class="col">
									<div data-tabulation-tab>Tab #1</div>
									<div data-tabulation-tab>Tab #2</div>
									<div data-tabulation-tab>Tab #3</div>
								</div>
								<div class="col">
									<a href="#" class="btn btn-light" data-tabulation-nav="1">1</a>
									<a href="#" class="btn btn-light" data-tabulation-nav="2">2</a>
									<a href="#" class="btn btn-light" data-tabulation-nav="3">3</a>
								</div>
							</div>
						</div>
					</div>
				</div>

				<div class="col-lg-6 mt-5">
					<div class="card js-tabulation1">
						<div class="card-header">
							Init with custom class
						</div>
						<div class="card-body">
							<div data-tabulation-tab>Tab #1</div>
							<div data-tabulation-tab>Tab #2</div>
							<div data-tabulation-tab>Tab #3</div>
							<div data-tabulation-tab>Tab #4</div>
							<div data-tabulation-tab>Tab #5</div>
						</div>
						<div class="card-footer">
							<a href="#" class="btn btn-info" data-tabulation-nav="prev">prev</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="1">1</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="2">2</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="3">3</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="4">4</a>
							<a href="#" class="btn btn-light" data-tabulation-nav="5">5</a>
							<a href="#" class="btn btn-info" data-tabulation-nav="next">next</a>
						</div>
					</div>
				</div>

				<div class="col-lg-6 mt-5">
					<div class="card js-tabulation2">
						<div class="card-header">
							Init with custom class
						</div>
						<div class="card-body">
							<div data-tabulation-tab>Tab #1</div>
							<div data-tabulation-tab>Tab #2</div>
							<div data-tabulation-tab>Tab #3</div>
							<div data-tabulation-tab class="tab-active">Tab #4</div>
							<div data-tabulation-tab>Tab #5</div>
						</div>
						<div class="card-footer">
							<a href="#" class="btn btn-info" data-tabulation-nav="prev">prev</a>
							<a href="#" class="btn btn-warning" data-tabulation-nav="1">1</a>
							<a href="#" class="btn btn-warning" data-tabulation-nav="2">2</a>
							<a href="#" class="btn btn-warning" data-tabulation-nav="3">3</a>
							<a href="#" class="btn btn-warning" data-tabulation-nav="4">4</a>
							<a href="#" class="btn btn-warning" data-tabulation-nav="5">5</a>
							<a href="#" class="btn btn-info" data-tabulation-nav="next">next</a>
						</div>
					</div>
				</div>

			</div>
		</div>
		<div class="related">
		    <h3>如果你喜欢这个插件,那么你可能也喜欢:</h3>
		    <a href="http://www.htmleaf.com/jQuery/Form/201802024963.html">
			  <img src="related/1.jpg" width="300" alt="简单的jquery前台分页插件paginathing.js"/>
			  <h3>简单的jquery前台分页插件paginathing.js</h3>
			</a>
			<a href="http://www.htmleaf.com/jQuery/jquery-tools/201711284851.html">
			  <img src="related/2.jpg" width="300" alt="jquery分页插件jqPaginator"/>
			  <h3>jquery分页插件jqPaginator</h3>
			</a>
		</div>
	
	<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
	<script src="js/jquery.tabulation.js"></script>
	<script>
		$('.js-tabulation1').tabulation({
			navigation: {
				active: {
					class: 'tabulation-active-button1'
				}
			}
		});
		$('.js-tabulation2').tabulation({
			navigation: {
				active: {
					class: 'btn-light'
				}
			},
			tabulation: {
				active: {
					class: 'tab-active'
				}
			}
		});
	</script>
</body>
</html>

效果图

在这里插入图片描述

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值