2013-04-07 22 views
0

我想說明兩個鏈接,當用戶在一個DIV移動鼠標,並隱藏他們當用戶離開DIV然後mousemoving,我這樣做:here it is顯示鏈接時,一個DIV是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> 

但沒有結果

我怎樣才能做到這一點

感謝

回答

0

使用這個JavaScript:

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

這是我自己寫這段代碼 – simonTifo 2013-04-07 19:36:12

+0

不,我把'#subdi'改成'#subdiv'和'mouseenter'改成'mouseover' – pietroalbini 2013-04-08 08:07:26

0

你想水木清華這樣?:

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