2017-01-13 1 views
1

div을 추가하는 코드 위에 간단한 마우스가 있습니다.jQuery MouseOut triggers mouseEnter

는 또한 mouseout에 대한 스크립트가 있지만 코드는

$(".actipntrg").on("mouseleave" , function() { $(this).remove(); }); }); 

답변

1

변경 "로 마우스"가 작동합니다 "하는 MouseLeave"하고있다 mouseenter

Demo

<div class="topicaction"> 
<i class="fa fa-caret-down edit-topic-open" aria-hidden="true">Hover</i>      
</div> 

$("body").on("mouseenter", ".edit-topic-open", function() { 
$(this).after('<div class="actipntrg"><span class="edit-topic" data-toggle="modal" data-target="#summernoteModal"><i class="fa fa-pencil-square-o" aria-hidden="true" data-value=""></i> Edit</span><span class="remove-topic"><i class="fa fa-times" aria-hidden="true" data-value=""></i> Remove </span><span class="cancel_a"><i class="fa fa-times" aria-hidden="true"></i> Cancel</span></div>'); 

$(".actipntrg").on("mouseout" , function() { 
     $(this).remove(); 
    }); 
}); 
+0

고마워, 나는 그것을 사용해 봤지만 브라우저에서 마우스를 움직일 때만 작동했다. 하지만 지금은 작동합니다 – SamotnyPocitac

+0

왜 mouseout이 작동하지 않았는지 설명 할 수 있습니까? – SamotnyPocitac

+0

마우스가 내부 요소를 벗어날 때 mouseout이 트리거됩니다. 이 예제에서 마우스는 .actipntrg를 남긴 다음 .edit-topic을 입력합니다. mouseleave를 사용하면 바인딩 된 요소를 떠날 때 트리거됩니다. 그래서 .actipntrg 안에 모든 것을 남겨두면됩니다. 더 나은 설명 http://api.jquery.com/mouseleave/ –

1

트리거 . 그래서 당신은 이것을 가지고 있습니다.

$(".actipntrg").on("mouseleave" , function() { 
    $(this).remove(); 
});