用jQuery實現一些導航條切換,顯示隱藏,主要運用的技術有slideToggle( ),toggeClass( ),toggle( ):
代碼如下:
導航條在項目中的應用$(function(){
$(".tit").find("span").click(function(){
$(this).toggleClass("closeBtn2").parent().next().slideToggle(); //實現內容隱藏顯示,及圖標的切換
}) ;
$(".clsBot").click(function(){
$(this).parent().find("li:gt(4)").toggle(); //實現內容索引值大于4的隱藏或者顯示
})
})
*{ margin: 0;padding: 0;}
ul li{ list-style: none;}
.box{ width: 400px; margin: 100px auto; border: 1px solid #ddd;}
.tit{ background: #999; height: 30px; color: #fff; font-size: 14px; line-height: 30px; padding-left: 6px; position: relative;}
.closeBtn{ background: url("Images/a2.gif") no-repeat 0 0; width: 7px; height: 8px; position: absolute; right: 10px; top: 10px; display: block; text-indent: -9999px; cursor: pointer;}
.closeBtn2{background: url("Images/a1.gif") no-repeat 0 0;}
.content{padding: 6px;font-size: 12px; overflow: hidden; }
.content li{ float: left; width: 100px; height: 24px; }
.content li a{ color: #999;}
.content li a:hover{ color: red;}
.clsBot{ display: block; clear: both; background: url("Images/a5.gif") no-repeat right 0; padding-right: 16px; float: right; width: 26px; cursor: pointer; color: blue;}
圖書分類
關閉
- 小說 ( 1110 )
- 文藝 ( 230 )
- 青春 ( 1430 )
- 少兒 ( 1560 )
- 生活 ( 870 )
- 社科 ( 1460 )
- 管理 ( 1450 )
- 計算機 ( 1780 )
- 教育 ( 930 )
- 工具書 ( 3450 )
- 引進版 ( 980 )
- 其它類 ( 3230 )
簡化
效果圖: