YUI 3.x Home -

YUI Library Examples: Node: DOM Methods

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

Node: DOM Methods

This example demonstrates how to use the DOM methods of a Node instance.

Click any of the boxes to move them to the other list.

  • lorem
  • ispum
  • dolor
  • sit
  • foo

Setting up the Node

First we need some HTML to work with.

Using DOM Methods

Most common DOM methods are available via Node instances. These can be used to add, remove, and retrieve other nodes.

Now we need a handler to move a node to a new list when the click event fires.

Note that appendChild returns a Node instance representing the node that was appended.

Listening for Node 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 © 2009 Yahoo! Inc. All rights reserved.

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