如何在HTML中单击隐藏或显示div [英] How to hide or show div on click in HTML

查看:1484
本文介绍了如何在HTML中单击隐藏或显示div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有四个HTML div 我想在点击时显示和隐藏它们如何操作

I have four HTML div I want to show and hide them on click how to do this

            <div id="targetid" class="image_one"><img src="image/imageone.png"/></div>
            <div id ="targetidone "class="image_two"><img src="image/imagetwo.png"/></div>
            <div id="targetidtwo" class="image_one_one"><img src="image/pagetwo_graph_two_11.png"/></div>
            <div id ="targetidfour"class="image_two_two"><img src="image/pagetwo_graph_two_22.png"/></div>

下面是两个 div 点击上面的图片应该隐藏并显示

below are those two div on which after click the above image should hide and show

          <div class="option_image"><img src="image/option_1.png"/></div>

          <div class="option_image_one"><img src="image/option_1.png"/></div>


推荐答案

$("buttonid").click(function () {
$("divid").toggle();
});

Buttonid - 您要点击的按钮的ID
divid - 你需要显示/隐藏

Buttonid - Id of the button which you will click divid - Id of the div which you need to show/hide

注意:包含jquery脚本

note:include jquery script

这篇关于如何在HTML中单击隐藏或显示div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆