diff -r 000000000000 -r 40c8f766c9b8 src/cm/media/js/lib/yui/yui_3.0.0b1/examples/node/basic-node.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.0.0b1/examples/node/basic-node.html Mon Nov 23 15:14:29 2009 +0100 @@ -0,0 +1,198 @@ + + + + + YUI Library Examples: Node: Node Basics + + + + + + + + + + + + +
+
+
+

+ + YUI 3.x Home - + +

+
+ + +
+ + + +
+
+
+
+

YUI Library Examples: Node: Node Basics

+
+
+ +

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

+ +
+
+
+
+ +

Node: Node Basics

+ +
+

+

This example demonstrates how to get and use a Node instance to access DOM properties.

+

Click the box to update the content of with the tagName of the click target's parentNode.

+

+ +
+
+ + + + +
+

Click me.

+
+ + + + + + +
+
+
+ +

Setting up the HTML

+

First we need some HTML to work with.

+ + +

Geting a Node Instance

+

We will get our Node instance using the get method of our YUI instance which accepts either an HTMLElement or a Selector string.

+ + +

Accessing Node Properties

+

The properties of a node can be accessed via its set and get methods.

+

In most cases, simple type of properties (strings, numbers, booleans) pass directly to/from the underlying DOM node, however properties representing other DOM nodes return Node or NodeList instances.

+

A click handler will allow us to update the content of our node with the tagName of its parentNode.

+

Note that the target of the event object will vary depending on where you click. The currentTarget of the event will always be the element that assigned the listener (the P element in this case).

+ + +

Listening for Node Events

+

We will update the node when the click event fires by 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

+
+
+ + + +