简体   繁体   中英

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

Hi suppose below is the code

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

If i hover on text the div with id showme should be shown and hide me should be hidden.Please provide me solution either in jscript or css.Thanks

on :hover of h1 the div will be visible and other div vill be 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> 

A possible jquery solution:

<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();
});

FIDDLE HERE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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