I'm kinda a beginner in HTML, so I'd like to ask your help. so I have this code: HTML:

我有点像HTML的初学者,所以我想问你的帮助。所以我有这个代码:HTML:

<div class="popup" onmouseover="popup()">
<span class="popuptext" id="myPopup">Click for more</span>

<button onclick="ak12M()"> <img id="ak-12" src="ak-12.png"/>AK-12</button> 
</div>
<input type="button" id="ak12B" value="Weapon info"             
onclick="location.href='http://symthic.com/bf4-weapon-info?w=AK-12'";/>
<p id="ak-12SZ">The AK-12, formerly AK-200,<br> is an accurate and powerful 
Russian Assault Rifle.<br> It fires the 5.45x39mm WP cartridge.</p>

CSS:

.popup {
position: relative;
display: inline-block;
cursor: pointer;
}


.popup .popuptext {
visibility: hidden;
width: 160px;
 color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
left:50%;
position: absolute;
z-index: 1;
bottom: 125%;
 background-color: #555;
margin-left: -80px;
}


.popup .popuptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent;
}


.popup .show {
visibility: visible;
-webkit-animation: fadeIn 1s;
animation: fadeIn 0.5s;
}


@-webkit-keyframes fadeIn {
from {opacity: 0;} 
to {opacity: 1;}
}

@keyframes fadeIn {
from {opacity: 0;}
to {opacity:1 ;}
}

Script:

function popup() {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
}

What I'd like to do, is that after I click on the button(the image), I'd like the pop up text to disappear Could you please tell me how to do it? Thanks for any help in advance

我想做的是,在我点击按钮(图像)之后,我想要弹出文本消失你能告诉我怎么做吗?在此先感谢您的帮助

1 个解决方案

#1


1

Here is an example you might find interesting:

这是一个你可能会感兴趣的例子:

function toggleInfo() {

  let text = document.getElementById("akText");
  
  if(text.style.visibility === 'hidden'){
    text.style.visibility = 'visible';
  } else {
      text.style.visibility = 'hidden';
  }
  

}
.akimage {
  width: 100px;
  height: 100px;
  background-color: green;
  line-height: 100px;
  text-align: center;
}
<div class="akimage" onclick="toggleInfo()">
  click me
</div>

<span id="akText">
  AKA text,   AKA text,   AKA text,  AKA text,
</span>

更多相关文章

  1. 已开启GTID的情况下的binlog复制切换到GTID复制可能会遇到的问题
  2. 我是初学者,使用mysql时候总是出现command denied to user
  3. Node.js和Geddy初学者指南 - 第三部分:使用Mongdb持久化你的数据
  4. 初学者的Selenium自动化测试指南,基于Python(五)——常用键盘事件
  5. 求高手推荐几本ANDROID开发初学者书籍
  6. 手低眼高 初学者学习Hibernate的方法

随机推荐

  1. mysql关键字与表名字段相同的解决方法
  2. 《PHP, MySQL, Javascript和CSS》读书随
  3. Deploying OpenFire for IM (instant mes
  4. PHP基础教程十四之使用MySqli操作数据库
  5. python中sqlite问题和坑
  6. Sql Server 2012 存储过程Demo1
  7. Django ORM - 获取组的最新记录
  8. SQLException:没有适合jdbc的驱动程序:de
  9. 记录不一致的数量-只改变是排序。
  10. 如何将表(及其行,列和单元格)保存在SQL数据