Javascript/Jquery 在 mouseout 上隐藏所有 h2

标签 javascript jquery css

当鼠标不在该区域上时,如何隐藏页面中的所有 h2 内容,并且仅在 javascript 或 CSS 中的鼠标悬停/悬停时显示

最佳答案

$(".redsquarecss")
  .hover(function() {
      $(".headers").show();
    },
    function() {
      $(".headers").hide()
    }
  );
div.redsquarecss {
  height: 150px;
  width: 150px;
  background-color: #FF0000;
}
div.headers {
  display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="redsquarecss" title="Square 1"></div>
<div class="headers">
  <h2>This is heading 2</h2>
  <h2>This is heading 2</h2>
  <h2>This is heading 2</h2>
</div>

https://jsfiddle.net/0r59so8r/1/

关于Javascript/Jquery 在 mouseout 上隐藏所有 h2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36677081/

相关文章:

javascript - 如何使用 Google map 绘制多条折线?

javascript - 使用 .live() 到 .autocomplete() 不会在 domchange 上触发

jquery - 从列表框移动到其他列表框

外部文件的 HTML 路径

javascript - 深入搜索属性值后返回对象

javascript - 将网页文本中的匹配词更改为按钮

javascript - Zurb Foundation - 下拉菜单不起作用

jQuery .width() 有时有效;有时不是吗?

html - IOS 中 safari 中的边框造成的差距

jquery - 如何正确覆盖 Jquery UI 样式