javascript - 如何显示/隐藏div点击图片

标签 javascript html css

我想在用户点击时显示/隐藏 div。我找到了 fiddle ,但它适用于输入,我想与图像集成。请帮助我。

#content {
  display: none;
}
input[type="text"]{
    color: transparent;
    text-shadow: 0 0 0 #000;
    padding: 6px 12px;
    width: 150px;
    cursor: pointer;
}
input[type="text"]:focus{
    outline: none;
}
input:focus + div#content {
  display: block;
}
<input type="text" value="CLICK TO SHOW CONTENT">
<div id="content">
and the content will show.
</div>

最佳答案

只显示图片而不是文本应该可以。

<input type="text" value="CLICK TO SHOW CONTENT">
<div id="content">
<img src="https://i.imgur.com/ZCbBNIt.png">
and the content will show.
</div>

参见:JsFiddle

关于javascript - 如何显示/隐藏div点击图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57162979/

相关文章:

css - SASS目录不会改变

html - 防止CSS网格导致溢出

javascript - Node : How to fix routing?

javascript - Firestore 云功能 - 使用 SendGrid 在Create 上发送电子邮件

html - 如何将行移动到最靠近第一行的顶部

php - 有没有办法在 gmail/wave/gdocs 中粘贴代码片段/ block ?

css - 拖动元素时如何保持样式?

Javascript 检查对象属性是否相等

javascript - Bootstrap 4 Modal with Tabs 内的 JQuery Validation Form 不会提交

c++ - BeagleBone -> HTML -> C++ 通信