成人精品一区二区三区中文字幕-成人精品一区二区三区-成人精品一级毛片-成人精品亚洲-日本在线视频一区二区-日本在线视频免费

導航首頁 ? 技術教程 ? 自己動手寫的jquery分頁控件(非常簡單實用)
全站頭部文字 我要出現在這里
自己動手寫的jquery分頁控件(非常簡單實用) 877 2024-03-22   

最近接了一個項目,其中有需求要用到jquery分頁控件,上網也找到了需要分頁控件,各種寫法各種用法,都是很復雜,最終決定自己動手寫一個jquery分頁控件,全當是練練手了。寫的不好,還請見諒,本分頁控件在chrome測試過,其他的兼容性不知道怎么沒時間測試呢。歡迎有同樣需求的小伙伴采用,在使用過程發現有問題歡迎提出批評建議。

查看圖片

css:

@charset "utf-";
* {
margin:px;
padding:px;
font-family:"微軟雅黑";
font-size:px;
}
._ul {
float:left;
height:px;
display:block;
}
._ul li {
list-style-type:none;
height:px;
width:px;
border:px solid #eee;
cursor:pointer;
text-align:center;
line-height:px;
color:blue;
float:left;
margin: px;
}
._ul li:hover,._before:hover,._after:hover {
border:px solid #f;
background: #ffff;
}

.li-hover {
border:px solid #f;
background: #ffff;
}

._before {
width:px;
height:px;
border:px solid #eee;
float:left;
cursor:pointer;
text-align:center;
line-height:px;
color:blue;
margin: px;
}
._after {
width:px;
height:px;
border:px solid #eee;
float:left;
cursor:pointer;
text-align:center;
line-height:px;
color:blue;
margin: px;
}

.Hidden {
display:none;
}
._select {
border:px solid #fff !important;
color:black !important;
}
._left {
float:left;
margin-left:px;
}
._right {
float:right;
margin-right:px;
}

js:

; (function ($, window, document, undefined) {
var isShow = function (ele,options) {
this.$element = ele,
this.defaults = {
maxpage: ,
count: ,
total: ,
float: 'right',
margin:'px',
getData:null
},
this.options = $.extend({}, this.defaults, options)
}
isShow.prototype={
showDiv:function(){
this.bindEvent();
},
showHtml:function(){
var _this = this, strHtml = "",count=Math.ceil(_this.options.total / _this.options.count);
strHtml += "<div class='"+(_this.options.float=='right'?'_right':'_left')+"'><div class='_before Hidden'><上一頁</div><ul class='_ul'>";
for (var i = ; i <= count ; i++) {
strHtml += "<li data-index='"+(i==?'frist':i==count?'last':'middle')+"' class='"+(i==?'_select':'')+" "+(i>_this.options.maxpage?'Hidden':'')+"'>"+i+"</li>";
}
strHtml += "</ul><div class='_after'>下一頁></div></div>";
_this.$element.append(strHtml);
},
MoveIndex:function(index){
var _this = this, _index = this.options.maxpage, count = Math.ceil(_this.options.total / _this.options.count);
var middle = _index / ;
var curr = _this.$element.find("li");
if (count <= _index) {
$(curr).show();
} else {
var ftemp = ,ltemp=;
if (index < middle)
ftemp = (middle - index);
if (middle > count - index)
ltemp=(middle-(count-index));
$(curr).each(function () {
var currindex = parseInt($(this).text());
if (currindex > index - middle-ltemp && currindex <= parseInt(index) + parseInt(middle)+ftemp) {
$(this).show();
} else {
$(this).hide();
}
});
} 
},
WhichFind:function(status,_index){
var _this=this;
switch (status) {
case 'frist':
_this.$element.find("._before").hide();
_this.$element.find("._after").show();
break;
case 'last':
_this.$element.find("._after").hide();
_this.$element.find("._before").show();
break;
case 'middle':
_this.$element.find("div").show();
break;
}
_this.MoveIndex(_index);
_this.options.getData({ index: _index });
},
bindEvent:function(){
var _this = this;
_this.showHtml();
_this.$element.find("li").click(function () {
var status = $(this).data("index"), _index = $(this).text();
$(this).addClass("_select").siblings().removeClass("_select");
_this.WhichFind(status,_index);
});

_this.$element.find("._before").click(function () {
var status = $("._select").prev().data("index"), _index = $("._select").prev().text();
$("._select").prev().addClass("_select").siblings().removeClass("_select");
_this.WhichFind(status,_index);
});

_this.$element.find("._after").click(function () {
var status = $("._select").next().data("index"), _index = $("._select").next().text();
$("._select").next().addClass("_select").siblings().removeClass("_select");
_this.WhichFind(status,_index);
});
}
}
$.fn.FY = function (option) {
var fs = new isShow(this, option);
return fs.showDiv();
}
})(jQuery,window,document);

以上內容是小編給大家分享的自己動手寫的jquery分頁控件(非常簡單實用),希望對大家有所幫助。


主站蜘蛛池模板: 娄际成| 黄真伊| 永远的日本电影| 都市频道节目表今天| 新手驾到综艺免费观看完整版| 七年级的英语翻译全书| 陈浩宇女演员| 绿门背后| 朋友的女友| 悠悠寸草心第一部| 小班健康活动教案40篇| 陈瑞的情债| 双男主动漫 推荐| 电影《斯宾塞》| 舞蹈压腿疼哭训练视频| 电影偿还| 2024厨房橱柜最新款图片视频| 人世间豆瓣| 永井大| 黑水电影| 黑咖啡早上空腹喝还是饭后喝| 洪金宝电影| 1988田螺姑娘| 中国天黑最晚的地方| 包青天之白玉堂传奇| 《美景之屋| 昭君出塞简谱| 金三角电影| 意大利a级情欲片女人城| 猫小帅的故事| 草逼啊啊啊| 周秀娜三级大尺度视频| 古灵精探演员表| 电影宝贝| 网页版抖音| 大世界扭蛋机 电视剧| 变形记开头结尾优美段落| 香港之夜完整版在线观看高清| 极品少妇啪啪久久蜜臀| 神迹电影| 骨妹|

!!!站長長期在線接!!!

網站、小程序:定制開發/二次開發/仿制開發等

各種疑難雜癥解決/定制接口/定制采集等

站長微信:lxwl520520

站長QQ:1737366103