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>www.dbjr.com.cn 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測試效果如下:
更多關(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é)》
希望本文所述對大家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實(shí)現(xiàn)div拖拽寬度示例代碼
本例為大家演示個(gè)比較簡單的div拖動(dòng),另外可根據(jù)自己的需求,添加相應(yīng)的代碼,實(shí)現(xiàn)自己的想要的效果,具體如下,喜歡的請支持下2013-07-07javascript向后臺傳送相同屬性的參數(shù)即數(shù)組參數(shù)
在傳送參數(shù)時(shí),經(jīng)常會(huì)碰到向后臺傳送一些相同屬性的參數(shù),最好的選擇是采用數(shù)組的方式,下面有個(gè)不錯(cuò)的示例,大家可以參考下2014-02-02編寫高效jQuery代碼的4個(gè)原則和5個(gè)技巧
有了JQuery對JS的整合和封裝,它讓頁面操作更加的隨心所欲,所以只有遵循良好的規(guī)范才會(huì)讓代碼更高效,更健壯。以下是我對如何高效操作JQuery的一些拙見,望指正!2014-04-04JQUERY的AJAX請求緩存里的數(shù)據(jù)問題處理
這篇文章主要介紹了JQUERY的AJAX請求緩存里的數(shù)據(jù)問題處理的相關(guān)資料,需要的朋友可以參考下2016-02-02jquery submit ie6下失效的原因分析及解決方法
jquery submit ie6下失效的原因分析及解決方法。需要的朋友可以過來參考下,希望對大家有所幫助2013-11-11jQuery .tmpl(), .template()學(xué)習(xí)資料小結(jié)
昨晚無意中發(fā)現(xiàn)一個(gè)有趣的jQuery插件.tmpl(),其文檔在這里。2011-07-07為jQuery增加join方法的實(shí)現(xiàn)代碼
正在做一個(gè)在線書簽管理的站點(diǎn),有需要這樣一個(gè)功能,把匹配節(jié)點(diǎn)的id或值拼合起來以用來傳遞參數(shù)。2010-11-11