Section 2 - Events
document is an HTML object in javascript an is used to handle any object that contains the html document.
Notice that it to is a selector.
It acts like a global object - that this can be done anywhere on the page.
.ready() is wait until all elements have been loaded.
Function is uniquely defined
Generally done before the execution of any function since it enforces safety.
document acts like a selector, but is more safe.
No difference would have been observed with 'html' as the selector.
Click Events
Now notice the difference here:
This is an HTML DOM element that is returned by the function it is invoked on, in our case the paragraph on the click event.
css invokations work exactly as any .css style pages.
It grabs a selector, in our case 'this', then takes a property and what attributes we want to invoke on that property. Just like:
The double click event
Hovering
Handled by mouseenter and mouseleave events.
Can handled by css alone
To combine and minimize both effects, we use the .hover function.
Notice that .hover is simply invoked with two arguments.
Keyboard Events
This event also captures keys when held down.
Unique keys
Does not capture keys held.
Also notice that both events are fired, and one does not overwrite the other.
Executed in sync. Multiple events are put into a queue.
Focus and Blur:
.focus is activates as a click event, and .blur resumes the opposite - that is, when a user clicks somewhere else.
Last updated
Was this helpful?