如果你有一个布尔值告诉你是否已经输入了怎么办?
有关 jQuery 事件的信息:MouseOver / MouseOut vs. MouseEnter / MouseLeave 看这里
// When the DOM is ready, init scripts.
jQuery(function( $ ){
var isEntered = false;
// Bind the mouse over /out to the first DIV.
$( "#mouse-control-div" ).bind(
"mouseover mouseout",
function( event ){
if(!isEntered)
{
isEntered = true;
echo('entered');
}
}
);
// Bind the mouse enter to the second DIV.
$( "#mouse-control-div" ).bind(
"mouseenter mouseleave",
function( event ){
if(isEntered)
{
isEntered = false;
echo('left');
}
}
);
function echo(string)
{
$('#output').append('<li>'+string+'</li>');
}
});
</p>
对于工作演示看这里