这篇文章主要为大家详细介绍了jquery初级教程之网站品牌列表效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了jQuery网站品牌列表效果展示的具体代码,供大家参考,具体内容如下
1.EG2.aspx
html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<script></script>
<link>
<script>
$(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>
2.样式表
jQuery 1.12.4是jQuery 1.x系列的最后一个正式稳定版本,由jQuery团队于2016年发布。该版本主要面向需要兼容旧版浏览器环境的网站和Web应用,尤其适用于仍需支持Internet Explorer 6、Internet Explorer 7、Internet Explorer 8等老旧浏览器的项目。
*{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.效果

图一

图二










