在Javascript / jQuery中(e)是什么意思? [英] In Javascript/jQuery what does (e) mean?
问题描述
我是JavaScript / jQuery的新手,我一直在学习如何制作功能。 (e)括号中出现了很多函数。让我告诉你我的意思:
$(this).click(function(e){
//做一些
});
它总是显示函数甚至不使用(e)的值,所以为什么它经常出现吗?
事件
将传递给事件处理程序的对象。
事件对象本质上有很多有趣的方法和属性可以用在事件处理程序中。
在您发布的示例中,它是一个点击处理程序,它是 MouseEvent
$ $ $ $ $ $(< ; //会返回你点击
}
DEMO - 鼠标事件DEMO使用 e.which
和 e.type
一些有用的参考资料:
http://api.jquery.com/category/events/
http://www.quirksmode.org/js/events_properties .html
http: //www.javascriptkit.com/jsref/event.shtml
。 http://www.w3.org/TR/DOM-Level-3-Events/#event-类型列表 I am new to JavaScript/jQuery and I've been learning how to make functions. A lot of functions have cropped up with (e) in brackets. Let me show you what I mean: It always appears that the function doesn't even use the value of (e), so why is it there so often? The event object essentially has lot of interesting methods and properties that can be used in the event handlers. In the example you have posted is a click handler which is a DEMO - Mouse Events DEMO uses Some useful references: http://api.jquery.com/category/events/ http://www.quirksmode.org/js/events_properties.html http://www.javascriptkit.com/jsref/event.shtml http://www.quirksmode.org/dom/events/index.html http://www.w3.org/TR/DOM-Level-3-Events/#event-types-list 这篇关于在Javascript / jQuery中(e)是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b $(this).click(function(e) {
// does something
});
e
is the short var reference for event
object which will be passed to event handlers.MouseEvent
$(<element selector>).click(function(e) {
// does something
alert(e.type); //will return you click
}
e.which
and e.type