jQuery-取消绑定或重新绑定hoverIntent()? [英] jQuery - unbind or rebind hoverIntent()?

查看:83
本文介绍了jQuery-取消绑定或重新绑定hoverIntent()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个菜单栏,在上一行显示一组类别.

I have a menu bar that displays a set of categories in an upper row.

其中一个类别具有一组子类别.

One of the categories has a set of sub-categories.

我有一个hoverIntent设置,以便它将在子菜单上向下滑动,并在鼠标离开时向上滑动.

I have a hoverIntent setup so that it will slideDown the submenu, and slideUp when the mouse leaves.

但是,如果我正在查看此类别中的页面,则希望该子菜单可见并突出显示活动类别.我还想确保当通过鼠标与子菜单进行交互时,一旦鼠标离开,它不会再次滑动.

However, if I am viewing a page in this category, I would like the submenu to be visible with the active category highlighted. I would also like to make sure that when the submenu is interacted with via the mouse, it does not slideUp again once the mouse leaves.

我试图在此页面的元素上重新声明hoverIntent函数,但它不起作用,它仍在使用先前的绑定.有什么方法可以解除上一个hoverIntent的绑定,并确保它使用了新的hoverIntent?

I have tried redeclaring the hoverIntent function on the element in this page but it does not work, it is still using the previous binding. Is there any way to unbind the previous hoverIntent and make sure it uses the new one?

推荐答案

要绑定和取消绑定hoverIntent,您应该执行以下操作:

to bind and unbind the hoverIntent you should do:

// bind the hoverIntent
$("#demo1 li").hoverIntent(makeTall, makeShort)
// unbind the hoverIntent
$("#demo1 li").unbind("mouseenter").unbind("mouseleave");
$("#demo1 li").removeProp('hoverIntent_t');
$("#demo1 li").removeProp('hoverIntent_s');
// rebind the hoverIntent
$("#demo1 li").hoverIntent(makeTall, makeShort)

这篇关于jQuery-取消绑定或重新绑定hoverIntent()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆