jQuery .mouseover().hover()函数之间有什么区别?如果它们完全相同,为什么jQuery同时使用这两种语言?

推荐答案

From the official jQuery documentation

  • .mouseover()
    Bind an event handler to the "mouseover" JavaScript event, or trigger that event on an element.

  • .hover()绑定一个或两个处理器

    拨打$(selector).hover(handlerIn, handlerOut)是以下的简写:


  • .mouseenter()

    绑定鼠标进入元素时要触发的事件处理程序,

    mouseover fires when the pointer moves into the child element as well, while mouseenter fires only when the pointer moves into the bound element.


What this means

因此,.mouseover().hover()相同,.mouseover().mouseenter()相同.

$('selector').mouseover(over_function) // may fire multiple times

// enter and exit functions only called once per element per entry and exit
$('selector').hover(enter_function, exit_function) 

Jquery相关问答推荐

JQuery DateTimePicker-在 Select 中抓取星期几

无法使用 HTML 设置未定义的 jQuery UI 自动完成的属性_renderItem

未捕获的类型错误:无法读取未定义的属性toLowerCase

如何在 Slick 轮播项目之间添加空格

从 JQuery.ajax 成功数据中解析 JSON

javascript:检测滚动结束

如何在 JQuery UI 自动完成中使用 source:function()... 和 AJAX

子元素点击事件触发父点击事件

scrollIntoView 是否适用于所有浏览器?

JQuery .hasClass 用于 if 语句中的多个值

在完成前一个请求之前中止新的 AJAX 请求

使用 JQuery / JavaScript 调用/单击 mailto 链接

通过 AJAX 和 jQuery 使用 HTML5 文件上传

停止输入/书写后如何触发输入文本中的事件?

如何在javascript中获取json键和值?

.apply jQuery 函数是什么?

在jquery中查找具有某个属性值的所有元素

用作 Google Chrome 书签

如何在 Bootstrap 中创建切换按钮

删除所有以某个字符串开头的类