2010-04-04 21 views
14

html của tôijquery mouseout vấn đề

<div id="parent"> 
<div id="child">cx</div> 
</div> 

khi tôi sử dụng jquery

$('#parent').mouseout(function(){ 
//something here 
}); 

tôi tự hỏi tại sao khi con chuột của tôi nhập vào đám cháy chức năng con div. Tôi vẫn còn trong div phụ huynh. tôi muốn rằng chức năng mouseout để bắn chỉ khi tôi rời khỏi div cha mẹ không khi tôi đang trên bất kỳ div con

http://jsbin.com/esiju/ < < dụ

Cheers

+0

Có thể trùng lặp: http://stackoverflow.com/questions/350639/how-to-disable-mouseout-events-triggered-by-child-elements –

Trả lời

1

.mouseleave công trình hoàn hảo ở đây:

$("#parent").mouseleave(function(){ 
    //Enter stuff that should happen when mouse leaves 
    //the boundaries of the parent element 
    // NOT including the children 
}); 

.mouseout cháy trên mousing trên yếu tố con!