<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<style type="text/css">
*{margin:0;padding:0;}
body{max-width: 640px; margin: 0 auto; font-family: 'Microsoft Yahei'}
.box{ overflow: hidden; }
.box dl{ overflow: hidden; margin-bottom: 10px; border: 1px solid #ddd; }
.box dt{ height: 45px; line-height: 45px; padding: 0 10px; background: #FADFF6; font-size: 18px; position: relative; cursor: pointer;}
.box dt span{ display: block; width: 0; height: 0; border-left:8px solid transparent; border-right: 8px solid transparent; position: absolute;right: 10px; top:15px; border-top: 8px solid #98479B}
.box dt span.on{
transform: rotate(180deg);
-ms-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-webkit-transform: rotate(180deg);
-o-transform: rotate(180deg);
}
.box dd{ overflow: hidden; padding: 10px; line-height: 34px; display: none;border-top: 1px solid #ddd; }
</style>
</head>
<body>
<div class="box" id="box">
<dl>
<dt>买书是最划算的投资<span></span></dt>
<dd style="display: block;">
<p>古人云:“书中自有黄金屋,书中自有颜如玉。”这说明先贤们早认识到,买书是最划算的投资。</p>
<p>我刚出道时,拿着非常微薄的工资。有一次向主管抱怨道:“现在的书真贵啊,这点工资连饭都吃不起,更别说买书了!”主管对我说:“不要吝惜买书的钱,宁可忍着不吃饭,也不要忍着不买书,因为买书是回报率最高的投资。”</p>
<p>主管的话让我非常震动。后来,我看到喜欢的书时,再也没有手软过。通过不断学习,我的开发能力不断提高,工资水平也大幅提高。一年后,我一个月工资的涨幅,就足够买两年的书了。你说,还有比这更划算的投资吗?</p>
<p>一本书,哪怕只有一页纸是有用的,它所将产生的潜在价值,也会远远超过书本身的价格。当然,书不在多,踏踏实实消化掉一本好书,比泛泛而读10本普通书,要有价值得多。</p>
</dd>
</dl>
<dl>
<dt>只学习与工作相关的东西<span></span></dt>
<dd>
<p>我曾发现不少程序员在学习方面找不到方向,一会儿学学C#,一会儿学学Java,看了最新的编程语言排行榜,又觉得该学C++。这样左抓抓,右挠挠,只会让你觉得更痒。</p>
<p>学习最忌三心二意。俗话说:“伤其十指不如断其一指”,每门都学一点,还不如专心学好一个方向。这个道理谁都懂,可是又该学哪个方向呢?难道只能跟着感觉走吗?不!最实际的方向,应该跟着工作走,工作需要什么,我们就学什么,把工作需要的技能熟练掌握,有很多好处。</p>
<p>首先,可以集中精力,在某一方面钻研得更加深入。所谓“百招会不如一招绝”,有了绝招,你还怕不能在“武林”立足吗?《天龙八部》中的慕容复武功博学无比,最后还不是被只会一招六脉神剑的段誉打得落花流水?</p>
<p>其次,可以学得更快、更深入,因为学习更具有针对性,而且可以立即在工作中运用,可以马上检验出学习的效果。对存在的问题进行深入研究,掌握的知识也会更加牢固。</p>
</dd>
</dl>
</div>
<script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
var obj = $('#box');
obj.find('dt').on('click',function(){
var thisSpan = $(this).children('span');
if(!thisSpan.hasClass('on')){
obj.find('dt').children('span').removeClass('on');
obj.find('dd').hide();
thisSpan.addClass('on');
$("html,body").scrollTop(thisSpan.offset().top-10);
$(this).siblings("dd").show();
}else{
thisSpan.removeClass('on');
$(this).siblings('dd').hide();
}
})
})
</script>
</body>
</html>

如图所示:

二、单个的展开收缩

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{margin:0;padding:0;}
.m_zi_tips{width: 300px; border:1px solid red; padding:10px; height: 40px; overflow: hidden;}
.m_zi_cur{ height: auto }
.m_zi_showicon{ background: red; width: 10px; height: 10px; overflow: hidden; }
</style>
</head>
<body>
<div class="m_zi_tips">
属牛的人性格:牛年出生的人――勤勉踏实。性格:沉默寡言,为人正直,纯朴,不愿伪装表面,富于耐性的同情心,具有勤劳,努力、坚毅的习惯,思考力强,坚持己见,容易失去益友,有老大气概,做事很精细,晚年将鸿图大展。
</div>
<a href="javascript:;" class="J_showtips"><span>展开</span></a>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$('.J_showtips').on('click',function(e){
if(!$('.m_zi_cur').length>0){
$('.m_zi_tips').addClass('m_zi_cur');
$(this).find('span').text("收起");
$(this).addClass('m_zi_showicon')
}else{
$('.m_zi_tips').removeClass('m_zi_cur');
$(this).find('span').text("展开");
$(this).removeClass('m_zi_showicon')
}
});
</script> </body>
</html>

效果图:

jquery展开收缩列表的更多相关文章

  1. 微信小程序 - 展开收缩列表

    代码源自于:微信小程序示例官方 index.wxml <block wx:for-items="{{list}}" wx:key="{{item.id}}" ...

  2. jQuery展开收缩2

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8& ...

  3. jQuery弹性展开收缩菜单插件gooey.js

    分享一款基于jQuery弹性展开收缩菜单插件gooey.js.这是一款基于gooey.js插件实现的弹性菜单特效代码.效果图如下: 在线预览   源码下载 实现的代码. html代码: <hea ...

  4. 可展开的列表组件——ExpandableListView深入解析

    可展开的列表组件--ExpandableListView深入解析 一.知识点 1.ExpandableListView常用XML属性 2.ExpandableListView继承BaseExpanda ...

  5. SlickGrid example 5:带子项的展开收缩

    带子项的展开收缩.   代码: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Ty ...

  6. WordPress文章页添加展开/收缩功能

    很多时候我们在WordPress上发布一些文章的时候里面都包含了很多的代码,我一般又不喜欢把代码压缩起来而喜欢让代码格式化显示,但是格式化显示通常会让文章内容看起来很多,不便于访问者浏览,所以今天就介 ...

  7. js之展开收缩菜单,用到window.onload ,onclick,

    目标效果:点击标签1,如果列表标签的style的display是block,改成none,否则改成block,来达到展开收缩菜单效果 一.准备阶段 html文件 <!DOCTYPE html&g ...

  8. max-height实现任意高度元素的展开收缩动画

    http://dobinspark.com.cn/ 前言: 在说到实现元素的展开收缩,通常的想法是通过控制display的元素属性和none之间的切换,虽然说功能可以实现,但是这种展开是没有任何动画的 ...

  9. jquery 展开折叠菜单

    jquery 展开折叠菜单 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <ht ...

随机推荐

  1. 最近学习的sql查询语句连接查询,标记一下

    select wordbase.name,wb.name,wordconnection.wordid,wordconnection.aid,wordbase.goodsid,goods.hscode, ...

  2. HRESULT:0x80070057 (E_INVALIDARG)

    笔记本蓝屏后,在vs2010中调试项目时出现该异常, 解决方法:清空C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Fi ...

  3. Quaternion.identity是什么意思?

    Quaternion.identity就是指Quaternion(0,0,0,0),

  4. 404. Sum of Left Leaves 左叶子之和

    [抄题]: Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are ...

  5. cactiez中文版10.1配置监控系统安装笔记

    1.安装虚拟机vmware_player2.创建虚拟机,设置桥接模式,内存4g,磁盘大小50G3.启动虚拟机,安装系统4.系统root 默认密码 CactiEZ5.配置网络静态IP,修改IP,网关等信 ...

  6. sqlserver服务器硬件性能瓶颈分析

    硬件性能瓶颈 内存 内存对SQL Server性能的影响胜过任何其他硬件.因此,对SQL Server系统的内存使用情况进行定期监视以确保内存的可用百分比高于20%是很有必要的.如果用户遭遇性能问题, ...

  7. 创建一个实例&创建一个线程。。

    using System; using System.Threading; namespace WorkerThread02 { class ThreadTest { bool done; stati ...

  8. 修改字段名change

    ALTER TABLE tc_activity_miaosha_item CHANGE `batch_id` `movie_batch_id` INT () NOT NULL DEFAULT ' CO ...

  9. tomcat端口作用

    <Server port="8005" shutdown="SHUTDOWN">   <Connector port="8080&q ...

  10. ubuntu 16.04安装ceph集群(双节点)

    Ceph是一个分布式存储,可以提供对象存储.块存储和文件存储,其中对象存储和块存储可以很好地和各大云平台集成.一个Ceph集群中有Monitor节点.MDS节点(可选,用于文件存储).至少两个OSD守 ...