国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery實戰之品牌展示列表效果

2019-11-20 23:51:36
字體:
來源:轉載
供稿:網友

只是初始狀態;

這是點擊后效果。首相分析下需求:
1,首先在頁面中創建導航,單擊標題的時候,隱藏內容,同時小圖標也改變。
2,單擊更多的時候,顯示隱藏的鏈接內容,并將"更多"變成"簡化",改變小圖標,并高亮部分鏈接。
下面是完整代碼:

復制代碼 代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb-2312">
<title>text</title>
<script type="text/javascript" src="jquery-1.4.2.js">
</script>
<style type="text/css">
*{ margin:0;padding:0;}
body{ font-size:13px;}
#wraper{ border:1px solid #ccc; width:301px; overflow:hidden;}
#wraper .Head{ background;#eee; padding:8px; height:18px; cursor:pointer;}
#wraper .Head h3{ float:left;}
#wraper .Head span{ float:right; margin-top:3px;}
#wraper .Content{ padding:8px;}
#wraper .Content ul{ list-style:none; list-style-type:none;}
#wraper .Content ul li{ float:left; width:95px; height:23px; line-height:23px;}
#wraper .Bot{ float:right; padding-top:5px; padding-bottom:5px;}
.GetFocus{ background:#eee;}
.one{ color:#ff8000;}
</style>
<script type="text/javascript">
$(function(){//頁面加載事件
$(".Head").click(function(){//圖片單擊事件
if($(".Content").is(":visible")){//如果內容可見
$(".Head span img").attr("src","Images/a1.gif");//改變圖片
//隱藏內容
$(".Content").hide();
}else{
$(".Head span img").attr("src","Images/a2.gif");//改變圖片
$(".Content").show();
}
});
var $chaLi = $(".Bot > a") ;
var $prompt = $("ul li:gt(4):not(:last)")
$prompt.hide();
$($chaLi).click(function(){//熱點鏈接單擊事件
//如果內容為簡化
if($chaLi.text() == "更多"){
//隱藏大于4 且不是最后一項的所有內容
$(".Bot img").attr("src","Images/a7.gif")
$prompt.show().addClass("GetFocus");
$("ul li").filter(":contains('青年'),:contains('老人'),:contains('少年')").addClass("one")
$($chaLi).text("簡化");
}else{
$prompt.hide()
$(".Bot img").attr("src","Images/a6.gif")
$($chaLi).text("更多");
}
})
})
</script>
</head>
<body>
<div id="wraper">
<div class="Head">
<h3>圖書分類</h3>
<span><img src="Images/a2.gif" alt=""/></span>
</div>
<div class="Content">
<ul>
<li><a href="#">小說</a><i>(1000)</i></li>
<li><a href="#">文藝</a><i>(1000)</i></li>
<li><a href="#">知音</a><i>(1000)</i></li>
<li><a href="#">少兒</a><i>(1000)</i></li>
<li><a href="#">生活</a><i>(1000)</i></li>
<li><a href="#">社科</a><i>(1000)</i></li>
<li><a href="#">廣利</a><i>(1000)</i></li>
<li><a href="#">美女</a><i>(1000)</i></li>
<li><a href="#">兒童</a><i>(1000)</i></li>
<li><a href="#">老人</a><i>(1000)</i></li>
<li><a href="#">少年</a><i>(1000)</i></li>
<li><a href="#">青年</a><i>(1000)</i></li>
<li><a href="#">成年</a><i>(1000)</i></li>
<li><a href="#">女人</a><i>(1000)</i></li>
<li><a href="#">父親</a><i>(1000)</i></li>
<li><a href="#">木青</a><i>(1000)</i></li>
<li><a href="#">母親</a><i>(1000)</i></li>
<li><a href="#">妹妹</a><i>(1000)</i></li>
<li><a href="#">其他</a><i>(1000)</i></li>
</ul>
</div>
<div class="Bot">
<a href="#">更多</a>
<img src="Images/a6.gif" />
</div>
</div>
</body>
</html>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 闵行区| 交城县| 寿阳县| 富宁县| 策勒县| 八宿县| 木兰县| 彭山县| 惠来县| 和静县| 喀喇| 丹巴县| 昌邑市| 道孚县| 新巴尔虎右旗| 大厂| 九江市| 老河口市| 板桥市| 龙州县| 福建省| 上饶县| 无锡市| 丽江市| 彩票| 报价| 彰化市| 田林县| 绥芬河市| 龙海市| 江口县| 大同市| 商洛市| 兴宁市| 丹江口市| 琼结县| 泰安市| 开原市| 庄河市| 顺义区| 开封市|