using on() with hover - jQuery

后端 未结 7 1208
感情败类
感情败类 2021-01-26 05:51

This is what I have:

$(\'#blah\').hover(function(){
    $(\'etc\').show();
}, function(){
    $(\'etc\').hide();
});

This works just fine, now

7条回答
  •  野的像风
    2021-01-26 06:01

    Use mouseenter and mouseleave for hover. Check using hover with on here.

    $("#blah").on(
    {
        mouseenter: function() 
        {
            //stuff to do on mouseover
        },
        mouseleave: function()
        {
            //stuff to do on mouseleave
        }
    });
    

    Use toggle to show / hide,

    $('#blah').on('hover', function(){
        $('#etc').toggle();
    });
    

提交回复
热议问题