简体   繁体   English

OnMouseOver在此显示,但OnMouseOut在隐藏

[英]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.) (格式化在stackoverflow上很奇怪。所以请忽略格式化。)

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 jsBin演示

Use CLASS .edit-banner 使用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);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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