<details> 标签用于描述文档或文档某个部分的细节。

<details>
<summary>Copyright 2011.</summary>
<p>All pages and graphics on this web site are the property of W3School.</p>
</details> 与 <summary> 标签 配合使用可以为 details 定义标题。标题是可见的,用户点击标题时,会显示出 details。

Demo

To see which browsers currently support this tag go to can I use website.

Please note at the time of writing this details tag is currently only supported in webkit browsers.

jQuery Version Of Details Tag

The problem with HTML5 at the moment is that it's still not fully supported mainly because people are still using out of date browsers such as IE6-8. The details tag is something that is not supported on many browsers so you might want to use the jQuery alternative.

This feature is something that can easy be done because of the slideToggle() method which you can just apply to the content on the click event of the title.

For this example we need to change the HTML.

<div class="jQueryDetailsExample">
<h2>Click Here For jQuery Version</h2>
<p>This is how it's done using jQuery</p>
</div>

We need to add the jQuery so it will do the same as the details tag, therefore we need to start off by hiding the paragraph which is our content so we can toggle the display. Then on the click event of the h2 tag we can toggle the paragraph.

Copy the following to copy the details functionality in jQuery.

$(document).ready(function(){
$(".jQueryDetailsExample p").hide(); $(".jQueryDetailsExample h2").click(function(){
$(this).siblings("p").slideToggle();
});
})

The jQuery example is also on the demo page please visit to see the different between them.

Demo

转自:http://www.paulund.co.uk/html5-details-tag

HTML 5 <details> 标签的更多相关文章

  1. HTML <span> 标签

    定义和用法: <span>标签被用来组合文档中的行内元素.在行内定义一个区域,也就是一行内可以被<span>划分成好几个区域,从而实现某种特定效果.<span>本身 ...

  2. Div和Span标签显示与隐藏

    本实例中,学习jQuery的知识,显示与隐藏网页上的div或是span标签. 实际环境中,也许是根据某些条件进行,符合条件时,对某个或是某个div或是span标签时行显示与隐藏. 主要是学习jQuer ...

  3. p标签中的span标签文字垂直居中对齐

    <p>轻舞飞扬<span>第一次亲密接触</span></p> p标签的font-size:30px; span标签的font-size:24px; 让 ...

  4. "无意义"的div和span标签

    HTML <div> 元素是块级元素,它是可用于组合其他 HTML 元素的容器.<div>元素没有特定的含义.除此之外,由于它属于块级元素,浏览器会在其前后显示折行.如果与 C ...

  5. 360兼容模式==ie8 兼容模式下 span标签占位问题

    ie8 兼容模式 ie8 标准渲染 应付金额 穿位 错误代码 <span class="span_em">应付金额:<em><span style=& ...

  6. html之span标签

    对于文档中的行内元素最好使用span来组合它们,这样就可以通过样式来格式化它们. span没有任何的样式,当对它应用样式时,才会产生变化 id和class属性是span标签的好伴侣,这样做既可以增加适 ...

  7. span标签之间的空隙

    出现的问题: 在html中,当有两个以及两个以上的span标签并列的时候,如果任意两个span之间换行书写的话,那么他们在页面上展现的时候往往会有空隙 解决的办法有两个: 1.将两个span标签写在同 ...

  8. display:block; 块级元素。<a>,<span>标签设置宽度和高度

    display:block;是让对象成为块级元素(比如a,span等) 转化后 可以对a或者span标签进行width和height设置,否则设置不了 display有很多对象,具体可以参考http: ...

  9. 使用<span>标签为文字设置单独样式

    这一小节讲解<span>标签,我们对<em>.<strong>.<span>这三个标签进行一下总结: 1. <em>和<strong& ...

  10. JS实现60s倒计时(亲测有效),及span标签如何使用和禁用onclick事件

    效果如下图:点击按钮出现60秒倒计时,60s内按钮不可用,倒计时到了时间方可再次点击获取. 另外还有一个知识点,只有input 及button这样的表单元素有disbale属性,如何设置是否可用属性的 ...

随机推荐

  1. Blog透视镜

    Blog透视镜,提供了Blog代码示例,文章和教程,可以帮助你建置博客. 网站名称:Blog透视镜 网站地址:http://blog.openyu.org

  2. 认识IL代码---从开始到现在 <第二篇>

    ·IL代码分析方法 ·IL命令解析 ·.NET学习方法论 1.引言 自从『你必须知道.NET』系列开篇以来,受到大家很多的关注和支持,给予了anytao巨大的鼓励和动力.俱往昔,我发现很多的园友都把目 ...

  3. 开源欣赏wordpress之post.php

    switch($action) { case 'postajaxpost': case 'post': case 'post-quickpress-publish': case 'post-quick ...

  4. 【转】Android下编译jni库的二种方法(含示例) -- 不错

    原文网址:http://blog.sina.com.cn/s/blog_3e3fcadd01011384.html 总结如下:两种方法是:1)使用Android源码中的Make系统2)使用NDK(从N ...

  5. iphone6闪存检测

    iPhone6自从发布以后一直又不少的诟病和非议,比如一机难求,容易掰弯,程序崩溃等, 甚至传出了苹果将要召回这些问题设备,最近有人终于查出了iPhone6安装大量程序后崩溃的原因,原因就是大容量的i ...

  6. sort,uniq命令

    文本排序:sort  默认以ASCII表排序    -n:数值排序    -r: 降序    -t: 字段分隔符    -k: 以哪个字段为关键字进行排序    -u: 排序后相同的行只显示一次   ...

  7. Multiscale Combinatorial Grouping 学习和理解源代码(一)

    目标探测由于所做的最新研究.因此,这一领域的一般阅读文章.发现这篇文章,效果是比较新的比较好.在如此仔细研究.贴纸和共享.下面已经发布若干个连续的,分别对论文和代码进行大致地介绍,最后依据自己的实验对 ...

  8. ThinkPHP中的__initialize()和类的构造函数__construct()

    ThinkPHP中的__initialize()和类的构造函数__construct()网上有很多关于__initialize()的说法和用法,总感觉不对头,所以自己测试了一下.将结果和大家分享.不对 ...

  9. 【数学.前左上计数法】【HDU1220】Cube

    Cube Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  10. stagefright框架(五)-Video Rendering

    AwesomePlayer::onVideoEvent除了透過OMXCodec::read取得解碼後的資料外,還必須將這些資料(mVideoBuffer)傳給video renderer,以便畫到螢幕 ...