Node: Node Events
This example demonstrates how to use events with Node instances.
Clicking a box will update its content.
- lorem
- ispum
Setting up the Node
First we need some HTML to work with.
Handling Events
Next we will add a handler to run when the event is fired. In our handler we will update the currentTarget with the type of the event.
Note that the event handler receives an event object with a Node instance as its currentTarget property.
Attaching Events
We can assign our handler to all of the items by using the all method to get a NodeList instance and using the on method to subscribe to the event.
