JavaScript: parameters for unnamed functions

In the following jQuery JavaScript code, what value does the "e" parameter inside the function take? It’s hard for me to understand this, because this function cannot be passed as an argument elsewhere in the code, and how would it work with a parameter? And how will I use parameters in functions that are not called and are not called anywhere else in the code?

    $(document).ready( function() { 
        $('div').each(function() {
            $(this).click(function(e){
                //some code
            });
        });
    });
+3
source share
3 answers

clickdefines an event handler. The click handler is called by the browser when an event occurs, and the parameter econtains information about this event.

, , (, ..).

.

. http://www.quirksmode.org/js/events_properties.html.

+7

e eventObject, jQuery .

, , click. , DOM.

+2

, e - eventObject:

click (fn)

// fn, a function to bind to the click event on each of the matched elements.
function callback(eventObject) {
  this; // dom element
}
+1

All Articles