繁体   English   中英

如何在悬浮图像或文本时隐藏一个div并隐藏另一个div?

[英]how to hide one div and hide another on hovering image or text?

您好,下面是代码

<h1>Hover Me</h1>
<div id="showme">Show</div>
<div id="hideme"><Hide</div>

如果我将鼠标悬停在文本上,则应显示id为showme的div并应将hide隐藏为隐藏。请以jscript或css为我提供解决方案。

on :hoverh1该div将visible而其他div vill hidden

 h1:hover ~ #showme, #hideme { display: block } h1:hover ~ #hideme, #showme { display: none } 
 <h1>Hover Me</h1> <div id="showme">Show</div> <div id="hideme">Hide</div> 

可能的jquery解决方案:

<h1 class='hover'>Hover Me</h1>
<div id="showme">Show</div>
<div id="hideme">Hide</div>

$('#hideme').show();
$('.hover').hover(function () {
    $('#hideme').hide();
}, function(){
    $('#hideme').show();
});

在这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM