jQuery+css實現(xiàn)的換頁標(biāo)簽欄效果
本文實例講述了jQuery+css實現(xiàn)的換頁標(biāo)簽欄效果。分享給大家供大家參考,具體如下:
運行效果截圖如下:

具體代碼如下:
<!DOCTYPE html>
<html>
<head>
<title>index</title>
<script type="text/javascript" src="jquery.js"></script>
<style type="text/css" >
body {
margin:0; padding:0; font-size:12px; color:gray;
}
.container {
height:200px; background:#F2F2F2; border-radius:6px;
-webkit-border-radius:6px; -moz-border-radius:6px; border:6px solid #D5D5D5;
}
.wrapper {
width:90%; margin:0px auto;
}
.pageContainer {
margin:0 auto; height:30px; position:relative; width:100%;
}
.page {
width:30px; height:30px; background:#494949; border-radius:30px; margin-left:5px;
-webkit-border-radius:30px; -moz-border-radius:30px; line-height:30px; font-size:15px;
display:block; text-align:center; color:#fff; float:left; cursor:pointer; float:left;
margin-top:5px;
}
.page:hover {
background:#42CFFD; font-weight:bolder;
}
.page.active {
background:#0864C0;
}
</style>
<script type="text/javascript" >
(function(){
$.fn.pageCreate = function(url, allPage, currentPage, pageTarget){
if(isNaN(allPage) || allPage < 1 || isNaN(currentPage) || currentPage < 1 || $.trim(url) == "") {
return;
}
var html = [],
self = $(this),
pageTarget = pageTarget?"":""
prevPage = currentPage > 1 ? currentPage - 1 : 0,
nextPage = currentPage < allPage ? currentPage + 1 : 0
left = '<a target="'+pageTarget+'" class="page" href="'+url+'1"><<</a><a target="'+pageTarget+'" href="'+(prevPage==0?"javascript:void(0)":url+prevPage)+'" class="page"><</a>',
right = '<a target="'+pageTarget+'" href="'+(nextPage==allPage?"javascript:void(0)":url+prevPage)+'" class="page">></a><a target="'+pageTarget+'" class="page" href="'+url+allPage+'" >>></a>';
html.push('<div class="pageContainer">');
html.push(left);
for(var i=currentPage; i<=allPage; i++) {
html.push('<a href="'+url+i+'" target="'+pageTarget+'" class="page '+(i==currentPage?"active":"")+'">'+i+'</a>');
}
html.push(right);
html.push('</div>');
self.html(html.join(''));
};
})();
$(document).ready(function(){
$('#pageContainer').pageCreate("http://localhost/?page=", 5, 3, '_blank');
});
</script>
</head>
<body>
<div class="wrapper">
<div class="container" id="pageContainer">
</div>
</div>
</body>
</html>
更多關(guān)于jQuery特效相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery常見經(jīng)典特效匯總》及《jQuery動畫與特效用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計有所幫助。
相關(guān)文章
BootStrap網(wǎng)頁中代碼顯示<code><pre>用法詳解
網(wǎng)頁中代碼的顯示,包括行中代碼顯示;成段的代碼顯示.本文給大家介紹bootstrap網(wǎng)頁中代碼顯示<code><pre>用法詳解,感興趣的朋友一起看看吧2016-10-10
jQuery插件bgStretcher.js實現(xiàn)全屏背景特效
可以自動動態(tài)更換網(wǎng)頁背景圖片的jQuery插件bgstretcher.js,sharejs.com推薦的這個插件,可以自定義多種方式讓網(wǎng)頁背景自動切換,效果流暢,非常難得,調(diào)用代碼也非常簡單。2015-06-06
JQuery 獲取json數(shù)據(jù)$.getJSON方法的實例代碼
這篇文章介紹了JQuery 獲取json數(shù)據(jù)$.getJSON方法的實例代碼,有需要的朋友可以參考一下2013-08-08
jquery 實現(xiàn)兩級導(dǎo)航菜單附效果圖
兩級導(dǎo)航菜單在網(wǎng)頁中非常實用,實現(xiàn)的方法也有很多,本文為大家介紹下使用jquery是如何實現(xiàn)的2014-03-03
jQuery使用animate實現(xiàn)ul列表項相互飄動效果示例
這篇文章主要介紹了jQuery使用animate實現(xiàn)ul列表項相互飄動效果,結(jié)合實例形式分析了jQuery使用animate動畫切換的操作技巧,需要的朋友可以參考下2016-09-09

