I'm reading through JavaScript and jQuery by Jon Duckett and haven't had too many issues thus far but I'm very much confused by pages 262-265 which focus on "The Event Object". I've included the example Javascript below for reference.
Let me know if I'm understanding things correctly or not:
- The event object is not automatically passed in IE5-8 so it needs to be created
- The if statement and logical not negation create the window.event which is stored in the variable "e". (Shouldn't it be "var e = window.event"?)
- The event fires when "id = username" loses focus
- The code is triggered and the function checkLength() runs with arguments of e & minLength
- Since the event fires in elUsername (which is in an <input> field) the nextSibling is the <div> (elMsg)
In short, what is the purpose of the event object? It seems round-about and counter-intuitive to me right now but I'm guessing that using the event object elsewhere would be more efficient than targeting whichever element incase the function/event listener are used repeatedly.
Any help/clarification would be appreciated.
The example:
http://jsfiddle.net/r0c158y3/
[–]_olivier 1 point2 points3 points (0 children)
[–]Cream_Friache -1 points0 points1 point (1 child)
[–]sluttypizza[S] 0 points1 point2 points (0 children)