2013-04-07 2 views
0

Je veux montrer deux liens lorsque l'utilisateur déplace la souris sur un div et les cacher lorsque l'utilisateur quitte la div, je fais ceci: here it islien show quand un div est mousemoving par jquery css

<div id="mydiv" style="background-color : red;width:100px;height:100px;position: relative;" > 
<div id="subdiv1" style="position: absolute;" > 
<a href="#" style="color:red;" >link 1</a> 
</br><a href="#" style="color:red;" >link 2</a> 
</div> 
<div id="subdiv2" style="width:60px;height:60px;background-color : blue;" ></div 
</div> 

mais aucun résultat

Comment puis-je obtenir ce

grâce

Répondre

0

Utilisez cette JavaScript:

$('#subdiv1').hide(); 
$('#subdiv2').mouseover(function(){ 
    $('#subdiv1').show(); 
}); 
$('#subdiv2').mouseleave(function(){ 
    $('#subdiv1').hide(); 
}); 
+0

c'est moi qui ai ecrire ce code – simonTifo

+0

Non, j'ai changé '# subdi' en' # subdiv' et 'mouseenter' en' mouseover' – pietroalbini

0

Voulez-vous SMTH comme ça ?:

http://jsfiddle.net/c6AnE/6/

HTML:

<div id="one"> 
    <a href="#">#1 link</a> 
    <a href="#">#2 link</a> 
</div> 
<div id="two"> 
</div> 

Jquery:

$("#two").mouseenter(function(){ 
     $("#one").hide(); 
    }); 
$("#two").mouseleave(function(){ 
     $("#one").show(); 
    }); 

CSS:

#one { 
    position:absolute; 
    background-color:red; 
    width:50px; 
    height:50px; 
} 
#two { 
    position:absoluite; 
    margin-left:30px; 
    background-color:blue; 
    width:60px; 
    height:60px; 
} 
Questions connexes