javascript 代码如下:
$(document).ready(function(){
$(".message_list .message_body:gt(0)").hide();
$(".message_list li:gt(4)").hide();
$(".message_head").click(function(){
$(this).next(".message_body").slideToggle(500)
return false;
});
//收起所有消息
$(".collpase_all_message").click(function(){
$(".message_body").slideUp(500)
return false;
});
//显示所有消息
$(".show_all_message").click(function(){
$(this).hide()
$(".show_recent_only").show()
$(".message_list li:gt(4)").slideDown()
return false;
});
//只显示最近的消息
$(".show_recent_only").click(function(){
$(this).hide()
$(".show_all_message").show()
$(".message_list li:gt(4)").slideUp()
return false;
});
});
css部分代码如下:
* {
margin: 0;
padding: 0;
}
body {
margin: 10px auto;
width: 570px;
font: 75%/120% Arial, Helvetica, sans-serif;
}
p {
padding: 0 0 1em;
}
.message_list {
list-style: none;
margin: 0;
padding: 0;
width: 383px;
}
.message_list li {
padding: 0;
margin: 0;
background: url(images/message-bar.gif) no-repeat;
}
.message_head {
padding: 5px 10px;
cursor: pointer;
position: relative;
}
.message_head .timestamp {
color: #666666;
font-size: 95%;
position: absolute;
right: 10px;
top: 5px;
}
.message_head cite {
font-size: 100%;
font-weight: bold;
font-style: normal;
}
.message_body {
padding: 5px 10px 15px;
}
.collapse_buttons {
text-align: right;
border-top: solid 1px #e4e4e4;
padding: 5px 0;
width: 383px;
}
.collapse_buttons a {
margin-left: 15px;
float: right;
}
.show_all_message {
background: url(images/tall-down-arrow.gif) no-repeat right center;
padding-right: 12px;
}
.show_recent_only {
display: none;
background: url(images/tall-up-arrow.gif) no-repeat right center;
padding-right: 12px;
}
.collpase_all_message {
background: url(images/collapse-all.gif) no-repeat right center;
padding-right: 12px;
color: #666666;
}HTML中添加代码如下:
<ol class="message_list">
<li>
<p class="message_head"><cite>张三:</cite> <span class="timestamp">1分钟前</span></p>
<div class="message_body">
<p>你好<br />
<br />
这是最后一条消息</p>
</div>
</li>
<li>
<p class="message_head"><cite>李四:</cite> <span class="timestamp">2分钟前</span></p>
<div class="message_body">
<p>你也好</p>
</div>
</li>
<li>
<p class="message_head"><cite>王五:</cite> <span class="timestamp">1天前</span></p>
<div class="message_body">
<p>第一次来</p>
</div>
</li>
<li>
<p class="message_head"><cite>李四:</cite> <span class="timestamp">2天前</span></p>
<div class="message_body">
<p>顶</p>
</div>
</li>
<li>
<p class="message_head"><cite>王五:</cite> <span class="timestamp">3天前</span></p>
<div class="message_body">
<p>支持</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/c1c2c2ed740f" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">Java免费学习笔记(深入)</a>”;</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/789">
<img src="https://img.php.cn/upload/ai_manual/001/503/042/68b6d94942638283.png" alt="讯飞开放平台">
</a>
<div class="aritcle_card_info">
<a href="/ai/789">讯飞开放平台</a>
<p>科大讯飞推出的以语音交互技术为核心的AI开放平台</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="讯飞开放平台">
<span>152</span>
</div>
</div>
<a href="/ai/789" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="讯飞开放平台">
</a>
</div>
</div>
</li>
<li>
<p class="message_head"><cite>李四:</cite> <span class="timestamp">5天前</span></p>
<div class="message_body">
<p>大家好</p>
</div>
</li>
<li>
<p class="message_head"><cite>张三:</cite> <span class="timestamp">6 天前</span></p>
<div class="message_body">
<p>大家好</p>
</div>
</li>
<li>
<p class="message_head"><cite>李四:</cite> <span class="timestamp">7天前</span></p>
<div class="message_body">
<p>这里不错哦</p>
</div>
</li>
<li>
<p class="message_head"><cite>王五:</cite> <span class="timestamp">8 天前</span></p>
<div class="message_body">
<p>好地方</p>
</div>
</li>
</ol>
<p class="collapse_buttons"><a href="#" class="show_all_message">显示所有消息(9)</a> <a href="#" class="show_recent_only">只显示五条消息</a> <a href="#" class="collpase_all_message">收起所有消息</a></p>
<br />
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号