欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery仿淘寶網(wǎng)產(chǎn)品品牌隱藏與顯示效果

 更新時間:2015年09月01日 17:42:15   作者:企鵝  
這篇文章主要介紹了jQuery仿淘寶網(wǎng)產(chǎn)品品牌隱藏與顯示效果,通過jquery鼠標(biāo)事件實(shí)現(xiàn)頁面元素的顯示與隱藏功能,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了jQuery仿淘寶網(wǎng)產(chǎn)品品牌隱藏與顯示效果。分享給大家供大家參考。具體如下:

這里演示jQuery實(shí)現(xiàn)產(chǎn)品品牌隱藏與顯示效果,仿淘寶網(wǎng)商品列表的品牌顯示與折疊功能,很實(shí)用的代碼,看了就知道了。

運(yùn)行效果截圖如下:

在線演示地址如下:

http://demo.jb51.net/js/2015/jquery-f-taobao-product-hidden-show-codes/

具體代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery產(chǎn)品品牌隱藏與顯示,仿淘寶網(wǎng)</title>
<style type="text/css">
*{ margin:0; padding:0;}
body {font-size:12px;text-align:center;}
a { color:#04D; text-decoration:none;}
a:hover { color:#F50; text-decoration:underline;}
.SubCategoryBox {width:600px; margin:0 auto; text-align:center;margin-top:40px;}
.SubCategoryBox ul { list-style:none;}
.SubCategoryBox ul li { display:block; float:left; width:200px; line-height:20px;}
.showmore { clear:both; text-align:center;padding-top:10px;}
.showmore a { display:block; width:120px; margin:0 auto; line-height:24px; border:1px solid #AAA;}
.showmore a span { padding-left:15px; background:url(images/down.gif) no-repeat 0 0;}
.promoted a { color:#F50;}
</style>
<!-- 引入jQuery -->
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){ // 等待DOM加載完畢.
 var $category = $('ul li:gt(5):not(:last)'); // 獲得索引值大于5的品牌集合對象(除最后一條) 
 $category.hide(); // 隱藏上面獲取到的jQuery對象。
 var $toggleBtn = $('div.showmore > a'); // 獲取“顯示全部品牌”按鈕
 $toggleBtn.click(function(){
  if($category.is(":visible")){
  $category.hide(); // 隱藏$category
  $('.showmore a span')
  .css("background","url(images/down.gif) no-repeat 0 0") 
   .text("顯示全部品牌"); //改變背景圖片和文本
   $('ul li').removeClass("promoted"); // 去掉高亮樣式
  }else{
   $category.show(); // 顯示$category
   $('.showmore a span')
   .css("background","url(images/up.gif) no-repeat 0 0") 
   .text("精簡顯示品牌"); //改變背景圖片和文本
   $('ul li').filter(":contains('佳能'),:contains('尼康'),:contains('奧林巴斯')")
  .addClass("promoted"); //添加高亮樣式
  }
  return false; //超鏈接不跳轉(zhuǎn)
 })
})
</script>
</head>
<body>
<div class="SubCategoryBox">
<ul>
<li ><a href="#">佳能</a><i>(30440) </i></li>
<li ><a href="#">索尼</a><i>(27220) </i></li>
<li ><a href="#">三星</a><i>(20808) </i></li>
<li ><a href="#">尼康</a><i>(17821) </i></li>
<li ><a href="#">松下</a><i>(12289) </i></li>
<li ><a href="#">卡西歐</a><i>(8242) </i></li>
<li ><a href="#">富士</a><i>(14894) </i></li>
<li ><a href="#">柯達(dá)</a><i>(9520) </i></li>
<li ><a href="#">賓得</a><i>(2195) </i></li>
<li ><a href="#">理光</a><i>(4114) </i></li>
<li ><a href="#">奧林巴斯</a><i>(12205) </i></li>
<li ><a href="#">明基</a><i>(1466) </i></li>
<li ><a href="#">愛國者</a><i>(3091) </i></li>
<li ><a href="#">其它品牌相機(jī)</a><i>(7275) </i></li>
</ul>
<div class="showmore">
<a href="#"><span>顯示全部品牌</span></a>
</div>
</div>
</body>
</html>

希望本文所述對大家的jquery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論