basic-node.mustache revision fb1ecdf65fd4106deb62da339763f2e7670ca0f6
1117N/A <p>This example demonstrates how to retrieve and use a <code>Node</code> instance to access DOM properties.</p>
1117N/A <p>Click the box to update the content with the <code>tagName</code> of the click target's <code>parentNode</code>.</p>
1117N/A<p>We will get our <code>Node</code> instance using the <code>one</code> method of our YUI instance which accepts either an HTMLElement or a Selector string.</p>
1117N/A<p>The properties of a node can be accessed via its <code>set</code> and <code>get</code> methods.</p>
1117N/A<p>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 <code>Node</code> or <code>NodeList</code> instances.</p>
1117N/A<p>A <code>click</code> handler will allow us to update the content of our node with the <code>tagName</code> of its <code>parentNode</code>.</p>
1117N/A<p>Note that the <code>target</code> of the event object will vary depending on where you click. The <code>currentTarget</code> of the event will always be the element that assigned the listener (the <code>P</code> element in this case).</p>
1117N/A // e.currentTarget === node
1117N/A e.currentTarget.one('em').setContent('I am a child of ' + tag + '.');