如何实现hoverintent插件

Ash*_*ley 11 html jquery menu hoverintent

我是jQuery的新手,想要将hoverintent插件添加到我的网站作为我的导航菜单.我被提到Brian Cherne的网站并看到要下载的代码,但我不太确定如何将它们放在一起以使其工作.有人可以使用添加的相应hoverintent插件代码发布html代码应该是什么样子吗?或者参考我的参考?我非常感激!谢谢!

gpa*_*sci 12

hoverIntent插件遵循jQuery hover方法的完全相同的api签名.您可以在http://cherne.net/brian/resources/jquery.hoverIntent.html上获取用法示例,只需查看源代码即可.

首先将jQuery包含在头部:

<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
Run Code Online (Sandbox Code Playgroud)

在下载之后并包含hoverIntent插件:

<script type="text/javascript" src="path/to/jquery.hoverIntent.js"></script>
Run Code Online (Sandbox Code Playgroud)

那么你可以hoverIntent()在任何像这样的jQuery元素上使用方法

$(element).hoverIntent(whatToDoWhenHover, whatToDoWhenOut);
Run Code Online (Sandbox Code Playgroud)

element是一个jQuery选择器喜欢'#id''.class''div > .something',whatToDoWhenHover并且whatToDoWhenOut是当用户开始悬停元素和停止时将执行的函数.就像旧的好jQuery悬停一样.