mouseenter and mouseleave of jQuery.on() delegated events

This is the syntax for a delegated event:

$(document).on('mouseeenter','.foo', function(){});

Here is the syntax for multiple events (without delegation):

$('.foo').on({
    mouseenter: function(){
        //stuff
    },
    mouseleave: function(){
        //stuff
    }
});

I'm wondering if there's a cleaner way to do this:

$(document).on('mouseenter', '.foo', function(){})
           .on('mouseleave', '.foo', function(){});
$(document).on({
    mouseenter: function(){
        //stuff
    },
    mouseleave: function(){
        //stuff
    }
}, '.foo');

Guess you like

Origin blog.csdn.net/weixin_40929263/article/details/120434830