鼠标的移入移出问题 e.relatedTarget

jquery封装 e.relatedTarget
 
在mouseover中相当于IE的event.fromElement,在mouseout中相当于IE的event.toElement

 

< href ="#"  class ="tip" >  Test1  </ a >
< href ="#"  class ="tip" >  Test2  </ a >
< href ="#"  class ="tip" >  Test3  </ a >
< div  id ="pop"  class ="test" >
 
< br /> 弹出层
 
< input  size ="12" />
 
< 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();
 });
})

 

你可能感兴趣的:(target)