javascript – HTML5,div,隐藏,点击显示

栏目: Html5 · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/25487865/html5-div-hidden-show-on-click

我有一个div,最后有一个按钮.我希望当有人按下那个按钮时,另一个div(在前一个下面)应该出现我把它放在div中的内容.

我使用以下代码:

HTML

<div>
    <a id="button" href="#">REGISTER</a>
</div>
<br>
<br>
<div id="item">
    <iframe src="some source" embedded=true" width="760" height="550" frameborder="0" marginheight="0" marginwidth="0">Loading</iframe>
</div>

和脚本的jquery:

<script>
    $(function() {
        $( "#button" ).click(function() {
            $( "#item" ).toggle();
        });
    });
</script>

我遇到的问题是第二个div最初出现在页面加载本身上,当我点击按钮时它就消失了.

我该怎么办?

HTML5使您可以使用详细信息标记轻松完成.
<details>
    <summary>Click to toggle division</summary>
    <p>Here you can put some content...</p>
    <p>... and anything else you want :)</p>
</details>

这是演示: https://jsfiddle.net/3wqyyf7m/

翻译自:https://stackoverflow.com/questions/25487865/html5-div-hidden-show-on-click


以上所述就是小编给大家介绍的《javascript – HTML5,div,隐藏,点击显示》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Once Upon an Algorithm

Once Upon an Algorithm

Martin Erwig / MIT Press / 2017-9-8 / GBP 22.95

How Hansel and Gretel, Sherlock Holmes, the movie Groundhog Day, Harry Potter, and other familiar stories illustrate the concepts of computing. Picture a computer scientist, staring at a screen and......一起来看看 《Once Upon an Algorithm》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具