mootools

    技术2022-07-11  123

    mootools

    jQuery offers a quick event shortcut method called hover that accepts two functions that represent mouseover and mouseout actions. Here's how to implement that for MooTools Elements.

    jQuery提供了一种称为悬停的快速事件快捷方法,该方法接受两个表示mouseover和mouseout动作的函数。 这是为MooTools Elements实现的方法。

    View Demo 观看演示

    MooTools JavaScript (The MooTools JavaScript)

    /* hover! */ Element.implement({ 'hover': function(fn1,fn2) { return this.addEvents({ 'mouseenter': function(e) { fn1.attempt(e,this); }, 'mouseleave': function(e) { fn2.attempt(e,this); } }) } });

    We implement hover() which accepts to functions; one will be called on mouseenter and the other on the mouseleave event. Each function is passed the corresponding event.

    我们实现了接受函数的hover() ; 一个将在mouseenter上被调用,另一个将在mouseleave事件上被调用。 每个函数都传递相应的事件。

    用法 (The Usage)

    /* fade in and out on hover event */ $('hover-me').hover(function(e) { this.fade('out'); }, function(e) { this.fade('in'); }); View Demo 观看演示

    This simple example usage makes use of element fading.

    这个简单的示例用法利用元素衰落。

    翻译自: https://davidwalsh.name/jquery-hover-mootools

    mootools

    相关资源:jdk-8u281-windows-x64.exe
    Processed: 0.009, SQL: 9