jQuery實(shí)現(xiàn)常見的隱藏與展示列表效果示例
本文實(shí)例講述了jQuery實(shí)現(xiàn)常見的隱藏與展示列表效果。分享給大家供大家參考,具體如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>m.fzitv.net jquery品牌列表效果</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel=" rel="external nofollow" stylesheet">
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
-moz-box-sizing: border-box;
}
body {
font: 16px/20px "Microsoft yahei,'微軟雅黑'"
color: #fff;
}
ul {
list-style-type:none;
}
a {
text-decoration: none;
color: #000;
}
ul li {
float: left;
text-align: right;
}
.clear:before,.clear:after {
content: "";
clear: both;
display: table;
height: 0;
overflow: hidden;
zoom: 1;
}
.SubCategoryBox {
width: 473px;
margin: 0 auto;
border: 1px solid;
}
.SubCategoryBox ul{
padding: 5px 10px;
}
.SubCategoryBox ul li {
padding: 5px;
}
.SubCategoryBox ul li:nth-child(3n-2) {
width: 130px;
}
.SubCategoryBox ul li:nth-child(3n-1) {
width: 161px;
margin-right: 30px;
}
.SubCategoryBox ul li:nth-child(3n) {
width: 130px;
}
.showmore {
text-align: center;
}
.showmore a {
background: #eef;
color: #CFCFE0;
}
.hightlight a,.hightlight i {
color: red;
/* font-weight: bold; */
}
</style>
</head>
<body>
<div class="SubCategoryBox">
<ul class="clear" id="bancon">
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >佳能</a><i>(30441)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >索尼</a><i>(30442)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >三星</a><i>(30443)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >尼康</a><i>(30444)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >松下</a><i>(30445)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >卡西歐</a><i>(30446)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >富士</a><i>(30447)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >柯達(dá)</a><i>(30448)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >賓得</a><i>(30449)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >理光</a><i>(30450)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >奧斯巴林</a><i>(30451)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >明基</a><i>(30452)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >愛國者</a><i>(30453)</i></li>
<li><a href="javascript:" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >其他品牌相機(jī)</a><i>(30454)</i></li>
</ul>
<div class="showmore" id="showpp">
<a href=""><span>顯示全部品牌</span></a>
</div>
</div>
<script src="http://cdn.bootcss.com/jquery/2.1.0/jquery.js"></script>
<script>
$(function(){
var $target=$("#bancon li:gt(5):not(:last)");
$target.hide();
var $toggleBtn=$("#showpp a");
$toggleBtn.click(function(){
if($target.is(":visible")){
$target.hide();
$(this).find("span").text("顯示所有品牌");
$("ul li").removeClass('hightlight')
}
else {
$target.show();
$(this).find('span').text("精簡顯示品牌");
$("ul li").filter(":contains('佳能'),:contains('尼康'),:contains('奧斯巴林')").addClass('hightlight')
}
return false; /*阻止a標(biāo)簽的跳轉(zhuǎn)*/
});
});
</script>
</body>
</html>
使用在線HTML/CSS/JavaScript代碼運(yùn)行工具 http://tools.jb51.net/code/HtmlJsRun測(cè)試效果如下:

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jquery中Ajax用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery動(dòng)畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)》
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
- jQuery簡單實(shí)現(xiàn)列表隱藏和顯示效果示例
- jquery實(shí)現(xiàn)點(diǎn)擊展開列表同時(shí)隱藏其他列表
- jquery點(diǎn)擊展示與隱藏更多內(nèi)容
- jquery特效 點(diǎn)擊展示與隱藏全文
- jQuery焦點(diǎn)控制圖層展示延遲隱藏的方法
- JQuery顯示、隱藏div的幾種方法簡明總結(jié)
- jQuery控制TR顯示隱藏的幾種方法
- jQuery控制TR顯示隱藏的三種常用方法
- Jquery 點(diǎn)擊按鈕顯示和隱藏層的代碼
- Jquery實(shí)現(xiàn)點(diǎn)擊切換圖片并隱藏顯示內(nèi)容(2種方法實(shí)現(xiàn))
相關(guān)文章
jQuery插件jquery-barcode實(shí)現(xiàn)條碼打印的方法
這篇文章主要介紹了jQuery插件jquery-barcode實(shí)現(xiàn)條碼打印的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了jQuery插件jquery-barcode的功能及打印條碼的實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-11-11
小巧強(qiáng)大的jquery layer彈窗彈層插件
這篇文章主要介紹了小巧強(qiáng)大的jquery layer彈窗彈層插件的使用方法以及使用范圍,非常詳細(xì),有需要的小伙伴可以參考下。2015-12-12
jquery中l(wèi)oad方法的用法及注意事項(xiàng)說明
本篇文章主要是對(duì)jquery中l(wèi)oad方法的用法及注意事項(xiàng)進(jìn)行了詳細(xì)介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2014-02-02
uploadify多文件上傳參數(shù)設(shè)置技巧
uploadify插件配置實(shí)用比較簡單,很多開發(fā)者都喜歡使用。但是它有個(gè)缺點(diǎn)就是剛加載的時(shí)候稍微慢了一秒左右,本文通過一段代碼實(shí)例給大家介紹uploadify多文件上傳參數(shù)設(shè)置技巧,朋友們一起學(xué)習(xí)吧2015-11-11
Jquery+ajax+JAVA(servlet)實(shí)現(xiàn)下拉菜單異步取值
這篇文章主要介紹了Jquery+ajax+JAVA(servlet)實(shí)現(xiàn)下拉菜單異步取值的相關(guān)資料,需要的朋友可以參考下2016-03-03
jquery簡單瀑布流實(shí)現(xiàn)原理及ie8下測(cè)試代碼
可以將分頁獲取的內(nèi)容依次填入四個(gè)div中,瀑布流的分頁可以以多頁(比如5頁)為單位二次分頁,這樣可以減少后臺(tái)算法的復(fù)雜度;測(cè)試環(huán)境:ie8 ff13.0.1 chrome22有興趣的朋友可以了解下2013-01-01

