SamotnyPocitac
SamotnyPocitac

Reputation: 402

jQuery MouseOut triggers mouseEnter

I have a simple mouse over code that appends div.

I also have a script for mouseout but it triggers on 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();
    });
});

Upvotes: 1

Views: 40

Answers (2)

The code is

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

Upvotes: 1

Luke Shepard
Luke Shepard

Reputation: 86

Change "mouseout" to "mouseleave" and it should work. So you have this.

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

Upvotes: 1

Related Questions