I have two divs: the red over the blue. I want that when the user hover the red this fadeOut and when hover the background (when he gets out of the blue) the red fadeIn. (What is more surprising to me is that the red fadeIn not when I hover the background but when I mouseleave it? I don't understand)
The example here life:http://jsfiddle.net/DpD8S/
HTML:
<div id="background">
<div id="red"></div>
<div id="blue"></div>
</div>
CSS:
#red{
position:absolute;
top: 20px;
left: 20px;
width: 60px;
height: 30px;
background-color:red;
cursor: pointer;
z-index: 1;
}
#blue{
position:absolute;
top: 20px;
left: 20px;
width: 60px;
height: 30px;
background-color:blue;
cursor: pointer;
}
#background{
position: relative;
margin: 0 auto;
width:300px;
height: 300px;
border: 1px solid;
border-color:#CCC;
text-align: center;
cursor: pointer; }
JQUERY:
$(function(){
$("#red").hover(function() {
$("#red").fadeOut();
});
$("#background").hover(function() {
$("#red").fadeIn("normal");
});
})