最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

JavascriptJQuery event arguments. I don't understand what this 'e' argument is or does - Stack Overflow

programmeradmin4浏览0评论

JQuery:

this.saveButton.click(function (e) {
    scope.saveForm();
});

This is a very simple line of JQuery that binds the .click() event to the saveButton object and calls a saveForm function when the event is fired.

When this event is called, what is 'e'? I don't think it is ever used.

JQuery:

this.saveButton.click(function (e) {
    scope.saveForm();
});

This is a very simple line of JQuery that binds the .click() event to the saveButton object and calls a saveForm function when the event is fired.

When this event is called, what is 'e'? I don't think it is ever used.

Share Improve this question asked Oct 12, 2011 at 13:53 contactmattcontactmatt 18.7k43 gold badges137 silver badges193 bronze badges 2
  • 5 e is Euler's number, approximately equal to 2.7182818284 -- it's heavily used in logarithms and calculus. Your puter doesn't know this constant, which is why it is absolutely essential that you include it in all your event handlers, or risk exploding the entire Internet. – Blazemonger Commented Oct 12, 2011 at 14:00
  • 2 Looking back on my ignorance years later. Priceless :) – contactmatt Commented Dec 11, 2014 at 0:12
Add a ment  | 

4 Answers 4

Reset to default 4

The e can be used to obtain specific information about the click (left, right or center; coordinates clicked; DOM object clicked on), but this specific code sample doesn't use it.

See http://api.jquery./category/events/event-object/ for details about what's available.

It's the event object. Take a look at the documentation page here:

http://api.jquery./click/

Event handlers can take an optional parameter that contains information about the event that occurred. In this case, it is unused.

e (or any other name you use) is an Event object. It is very useful when you, for example want to determine where did the click event take place or which key was pressed on keydown event.

You should read this article on jQuery API.

Example usage:

$("#someInput").keydown(function (e) {
  alert(e.which) // alerts the keycode of the pressed key
});
发布评论

评论列表(0)

  1. 暂无评论