YUI 3.x Home -

YUI Library Examples: Node: Node Events

Note: This is YUI 3.x. Looking for YUI 2.x?

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.

Full Script Source

Copyright © 2008 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings