Jquery mouseover and mouseout keeps flashing

别说谁变了你拦得住时间么 提交于 2019-12-01 05:54:27

DEMO

Use mouseenter and mouseleave instead.

$(document).ready(function () {

    $('.section-text').hide();

    $('.section-item-portal').mouseenter(function () {
        $(this).children('.section-text').fadeIn();
    });

    $('.section-item-portal').mouseleave(function () {
        $(this).children('.section-text').fadeOut();
    });

});

try this

$(document).ready(function() {
    $('.section-text').hide();

    $('.section-item-portal').hover(function() {
        $(this).children('.section-text').fadeIn();
    },function(){
        $(this).children('.section-text').fadeOut();
    });

});

In jQuery, both mouseover() and mouseenter() events are fire when the mouse enters the matched element. The only different is in the way of the “event bubbling” handle in child element Ref:http://www.mkyong.com/jquery/different-between-mouseover-and-mouseenter-in-jquery/

Please find the answer in jsfiddle.. http://jsfiddle.net/Dn6Rq/1/

$(document).ready(function () {

    $('.section-text').hide();

    $('.section-item-portal').mouseenter(function () {
        $(this).children('.section-text').fadeIn();
    });

    $('.section-item-portal').mouseleave(function () {
        $(this).children('.section-text').fadeOut();
    });

});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!