Пример:
В примере отображается текст, когда события mouseover и mouseout запущены. Mouseover событие запускается, когда указатель передвигается внутрь или удаляется от элемента до тех пор пока не произошло событие mouseenter.
"jQuery"
var i = 0;
$("div.overout").mouseover(function(){
$("p:first",this).text("Курсор находится в пределах границ элемента");
$("p:last",this).text(++i);
}).mouseout(function(){
$("p:first",this).text("Курсор вышел за границы элемента");
});
var n = 0;
$("div.enterleave").bind("mouseenter",function(){
$("p:first",this).text("Курсор находится в пределах границ элемента");
$("p:last",this).text(++n);
}).bind("mouseleave",function(){
$("p:first",this).text("Курсор вышел за границы элемента");
});
"HTML"
<div class="out overout">move your mouse
<div class="in overout">move your mouse
0
</div>0
</div> <div class="out enterleave">move your mouse
<div class="in enterleave">move your mouse
0
</div>0
</div>
"CSS"
div.out {
width:40%;
height:120px;
margin:0 15px;
background-color:#D6EDFC;
float:left;
}
div.in {
width:60%;
height:60%;
background-color:#FFCC00;
margin:10px auto;
}
p {
line-height:1em;
margin:0;
padding:0;
}
"Живой пример jQuery"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="http://slyweb.ru/css/jqueryiframe.css"
rel="stylesheet" type="text/css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
var i = 0;
$("div.overout").mouseover(function(){
$("p:first",this).text("Курсор находится в пределах границ элемента");
$("p:last",this).text(++i);
}).mouseout(function(){
$("p:first",this).text("Курсор вышел за границы элемента");
});
var n = 0;
$("div.enterleave").bind("mouseenter",function(){
$("p:first",this).text("Курсор находится в пределах границ элемента");
$("p:last",this).text(++n);
}).bind("mouseleave",function(){
$("p:first",this).text("Курсор вышел за границы элемента");
});
});
</script>
</head>
<body class="iframe">
<div class="out overout">move your mouse
<div class="in overout">move your mouse
0
</div>0
</div>
<div class="out enterleave">move your mouse
<div class="in enterleave">move your mouse
0
</div>0
</div>
</body>
</html>
<style>
div.out {
width:40%;
height:120px;
margin:0 15px;
background-color:#D6EDFC;
float:left;
}
div.in {
width:60%;
height:60%;
background-color:#FFCC00;
margin:10px auto;
}
p {
line-height:1em;
margin:0;
padding:0;
}
</style>