This article mainly introduces the website brand list effect of the jQuery beginner tutorial in detail. It has a certain reference value. Interested friends can refer to it.
The example in this article shares the jQuery website with everyone. The specific code for brand list effect display is for your reference. The specific content is as follows
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. Style sheet
*{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. Effect
Picture 1
Picture 2
The above is the detailed content of jQuery implements website brand list effect. For more information, please follow other related articles on the PHP Chinese website!