gpt4 book ai didi

javascript - 如何在 WordPress 中覆盖 JS 函数

转载 作者:行者123 更新时间:2023-11-30 12:03:34 24 4
gpt4 key购买 nike

试图从另一个函数覆盖 handlerOut(mouseleave)效果:

 $( '.main-nav .menu-item' ).hover(
function() {
$( '> .sub-menu' , this )
.stop( true, true )
.fadeIn( { duration: 250 } );

}, function() {
$( '> .sub-menu' , this )
.stop( true, true )
.fadeOut( { duration: 250 } );
} );

我不希望元素淡出但不确定如何覆盖它。是否可以使用其他功能阻止悬停效果的发生?

最佳答案

您可以使用 .off 删除事件处理程序并附上你自己的。您必须确保您的脚本在另一个脚本之后运行。

Note : .off works for jQuery 1.7 or newer, if you are using an older version see .unbind

$('.main-nav .menu-item')
.off('mouseenter mouseleave')
.hover( /* your own hover functions */ );

或者如果您不想更改过度效果,则只需 mouseleave 事件:

$('.main-nav .menu-item')
.off('mouseleave')
.mouseleave( /* your own hiding function */ );

关于javascript - 如何在 WordPress 中覆盖 JS 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35968416/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com