简体   繁体   中英

OnMouseOver this, show this but OnMouseOut, hide it

<div class="profile-banner" onMouseOver="fadeIn('edit-banner');" onMouseOut="fadeOut('edit-banner');">
    <div id="edit-banner">
        Edit Banner
    </div>
</div>

(Formating is being weird on stackoverflow.. so ignore the formating.)

Anywho, the problem I'm having is the second I put my mouse over the "Edit banner" area, it recognizes that i'm on another element, so it fades it out. I need it to stay as long as i'm in that profile-banner area.

jsBin demo

Use CLASS .edit-banner

<div class="profile-banner">
    <div class="edit-banner">
        Edit Banner
    </div>
</div>
$('.profile-banner').on('mouseenter mouseleave',function( e ){
    var inOut = e.type=='mouseenter' ? 1 : 0;
    $(this).find('.edit-banner').stop().fadeTo(500, inOut);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM