so i have been programming JS for a while now , and basically i never really understood one thing , I.E. the e
in events , have a look at the code below :
have a look at the HTML code :
<a href="https://developer.mozilla.org/en-US/docs/Web/Events/keydown">Hello</a>
Jquery code :
$(function () {
$('a').click(function(e){
console.log(e.target)
})
});
now what is e
in the above code , i understand the following :
e is an object normalized by jquery and is being internally passed
also i have come across the following explanation :
The functions you are referring to are called callback functions. Parameters for those are passed from within the function that is calling them ( in your case .on() or .click() )
to better illustrate how callback functions work here is an example
function customFunction ( param1, callback ) {
var response = "default response";
if (param1 === "hello") {
response = "greeting";
}
callback(response);
}
customFunction("hello", function(e) {
console.log("this is " + e);
}); // > this is greetings
I have read a famious thread on SO here. , but it only answers what e is and not where it comes from .
BUT I still don't understand where that e is coming from . can somebody explain in a bit of detail ?
Thanks .
Alex-z