这篇文章主要为大家详细介绍了jquery初级教程之网站品牌列表效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了jquery网站品牌列表效果展示的具体代码,供大家参考,具体内容如下
1.eg2.aspx
<!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 runat="server">
<title></title>
<script src="jquery-1.9.1.min.js" type="text/javascript"></script>
<link href="eg2.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function () {
var category = $("p.subname ul li:gt(3)"); // 获得索引值大于3的集合对象
category.hide(); // 隐藏上面获取到的jquery对象。
var showbtn = $("p.allname>a");
showbtn.click(function () {
if (category.is(":visible")) {
category.hide();
$(this).find('span').css("background", "url(img/down.gif) no-repeat 0 0").text("显示全部地方");
$("ul li").removeclass("promoted"); // 去掉高亮样式
} else {
category.show();
$(this).find("span").css("background", "url(img/up.gif) no-repeat 0 0").text("显示部分地方");
$("ul li").filter(":contains('南京'),:contains('内蒙古'),:contains('三亚')").addclass("promoted"); //为特定内容添加高亮样式
}
return false;//超链接不跳转
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<p class="subname" >
<ul>
<li><a href="#">南京</a></li>
<li><a href="#">北京</a></li>
<li><a href="#">内蒙古</a></li>
<li><a href="#">杭州</a></li>
<li><a href="#">三亚</a></li>
<li><a href="#">青岛</a></li>
<li><a href="#">海南</a></li>
<li><a href="#">云南</a></li>
<li><a href="#">厦门</a></li>
<li><a href="#">重庆</a></li>
<li><a href="#">香港</a></li>
</ul>
<p class="allname">
<a href="#"><span>显示全部地方</span></a>
</p>
</p>
</form>
</body>
</html>
2.样式表
*{margin:0;padding:0;}
body {font-size:12px;text-align:center;}
a{color:#04d; text-decoration:none;}
a:hover{ color:#f50; text-decoration:none;}
.subname{width:600px; margin:0 auto; text-align:center;margin-top:40px;}
.subname ul{list-style:none;}
.subname ul li{display:block; float:left; width:200px; line-height:20px;}
.allname { clear:both; text-align:center;padding-top:10px;}
.allname a { display:block; width:120px; margin:0 auto; line-height:24px; border:1px solid #aaa;}
.allname a span { padding-left:15px; background:url(img/down.gif) no-repeat 0 0;}
.promoted a { color:#f50;}
3.效果
图一
图二
以上就是jquery实现网站品牌列表效果的详细内容。