Why is the "event" variable available even if it is not passed as a parameter?
It is not so reliable. For example, this code will not work in Firefox.
Microsoft used the global variable event . DOM2 defined it as an argument to the handler. Chrome decided to drop the MS-specific bone code and do both. Firefox did not.
Even in browsers that run this code, note that event will be a raw event, not a jQuery-enhanced one. This means that, for example, in IE8 you cannot call event.preventDefault , because IE8 does not provide this function. jQuery will be if you accept the argument because jQuery provides an event object with standard functions even in browsers that do not have these functions.
TJ Crowder Oct. 16 '15 at 9:38 2015-10-16 09:38
source share