jquery封装
e.relatedTarget
在mouseover中相当于IE的event.fromElement,在mouseout中相当于IE的event.toElement
<
a
href
="#"
class
="tip"
>
Test1
</
a
>
< a href ="#" class ="tip" > Test2 </ a >
< a href ="#" class ="tip" > Test3 </ a >
< div id ="pop" class ="test" >
< br /> 弹出层
< input size ="12" />
< a href ="#" > aaaaaa </ a >
< br />
</ div >
< a href ="#" class ="tip" > Test2 </ a >
< a href ="#" class ="tip" > Test3 </ a >
< div id ="pop" class ="test" >
< br /> 弹出层
< input size ="12" />
< a href ="#" > aaaaaa </ a >
< br />
</ div >
$(
function
(){
$( " .tip " ).hover( function (e){
$( " #pop " ).css({
" position " : " absolute " ,
" top " : $(this).offset().top + $(this).outerHeight() ,
" left " : $(this).offset().left
}).show();
}, function (e){
if ( $(e.relatedTarget).attr( " id " )! = " pop " ){ $( " #pop " ).hide();
}
});
$( " #pop " ).bind( " mouseleave " , function (){
$( ' #pop ' ).hide();
});
})
$( " .tip " ).hover( function (e){
$( " #pop " ).css({
" position " : " absolute " ,
" top " : $(this).offset().top + $(this).outerHeight() ,
" left " : $(this).offset().left
}).show();
}, function (e){
if ( $(e.relatedTarget).attr( " id " )! = " pop " ){ $( " #pop " ).hide();
}
});
$( " #pop " ).bind( " mouseleave " , function (){
$( ' #pop ' ).hide();
});
})