例.网站品牌列表的效果
2012-05-03 14:32
483 查看
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
* {
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;
}
/*
* 步骤:
* 1.从第7条开始隐藏后面的品牌,最后一条除外
* 2.当用户点击"显示全部品牌"后,
* (1)显示隐藏的品牌
* (2)“显示全部品牌“文本切换成”精简显示品牌“
* (3)高亮推荐品牌
* 3.当用户点击”精简显示品牌"后
* (1)从第7条开始隐藏后面的品牌,最后一条除外
* (2)"精简显示品牌“文本切换成”显示全部品牌“
* (3)去掉高亮的推荐品牌
* 4.循环进行第2步和第3步
* */
$(function () { // 等待DOM加载完毕.
var $category = $("ul li:gt(5):not(:last)"); // 获得索引值大于5的品牌集合对象(除最后一条)
$category.hide(); // 隐藏上面获取到的jQuery对象。
var $toggleBtn = $("div.showmore a span"); // 获取“显示全部品牌”按钮
$toggleBtn.click(function () {
if ($category.is(":visible")) {
$category.hide(); // 隐藏$category
$toggleBtn
.css("background", "url(images/down.gif) no-repeat 0 0")
.text("显示全部品牌"); //改变背景图片和文本
$("ul li").removeClass("promoted");// 去掉高亮样式
} else {
$category.show(); // 显示$category
$toggleBtn
.css("background", "url(images/up.gif) no-repeat 0 0")
.text("精简显示品牌"); //改变背景图片和文本
$("ul li")
.filter(":contains('索尼'),:contains('尼康'),:contains('柯达'),:contains('奥林巴斯')")
.addClass("promoted"); //添加高亮样式
}
return false; //超链接不跳转
});
});
佳能(30440)
索尼(27220)
三星(20808)
尼康(17821)
松下(12289)
卡西欧(8242)
富士(14894)
柯达(9520)
宾得(2195)
理光(4114)
奥林巴斯(12205)
明基(1466)
爱国者(3091)
其它品牌相机(7275)
显示全部品牌
* {
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;
}
/*
* 步骤:
* 1.从第7条开始隐藏后面的品牌,最后一条除外
* 2.当用户点击"显示全部品牌"后,
* (1)显示隐藏的品牌
* (2)“显示全部品牌“文本切换成”精简显示品牌“
* (3)高亮推荐品牌
* 3.当用户点击”精简显示品牌"后
* (1)从第7条开始隐藏后面的品牌,最后一条除外
* (2)"精简显示品牌“文本切换成”显示全部品牌“
* (3)去掉高亮的推荐品牌
* 4.循环进行第2步和第3步
* */
$(function () { // 等待DOM加载完毕.
var $category = $("ul li:gt(5):not(:last)"); // 获得索引值大于5的品牌集合对象(除最后一条)
$category.hide(); // 隐藏上面获取到的jQuery对象。
var $toggleBtn = $("div.showmore a span"); // 获取“显示全部品牌”按钮
$toggleBtn.click(function () {
if ($category.is(":visible")) {
$category.hide(); // 隐藏$category
$toggleBtn
.css("background", "url(images/down.gif) no-repeat 0 0")
.text("显示全部品牌"); //改变背景图片和文本
$("ul li").removeClass("promoted");// 去掉高亮样式
} else {
$category.show(); // 显示$category
$toggleBtn
.css("background", "url(images/up.gif) no-repeat 0 0")
.text("精简显示品牌"); //改变背景图片和文本
$("ul li")
.filter(":contains('索尼'),:contains('尼康'),:contains('柯达'),:contains('奥林巴斯')")
.addClass("promoted"); //添加高亮样式
}
return false; //超链接不跳转
});
});
佳能(30440)
索尼(27220)
三星(20808)
尼康(17821)
松下(12289)
卡西欧(8242)
富士(14894)
柯达(9520)
宾得(2195)
理光(4114)
奥林巴斯(12205)
明基(1466)
爱国者(3091)
其它品牌相机(7275)
显示全部品牌
相关文章推荐
- jQuery只网站品牌列表的效果
- 网站品牌列表效果 jQuery效果
- jQuery初级教程之网站品牌列表效果
- 案例----某网站品牌列表的效果
- 模拟网站品牌列表的效果
- 2.6: 案例研究---某网站品牌列表的效果
- 某网站品牌列表效果
- jQuery某网站品牌列表效果
- 2.6: 案例研究---某网站品牌列表的效果
- jq代码学习3--某网站品牌列表的效果 fl ch2 p53
- 网站品牌列表效果
- jQuery实战之品牌展示列表效果
- 购物网站17-1:产品action---品牌列表---品牌管理---生成产品静态页面---前台产品管理----产品列表----产品管理
- jquery实现网站列表切换效果的2种方法
- 使用jQuery和CSS3创建一个支持翻转效果的微/轻博客网站列表
- 使用jQuery和CSS3创建一个支持翻转效果的微/轻博客网站列表
- jQuery实战之品牌展示列表效果
- Asp.net MVC3 企业网站系统高仿博客园 首页左侧列表页面 实现效果
- 使用jQuery和CSS3创建一个支持翻转效果的微/轻博客网站列表
- jQuery实战之品牌展示列表效果