<div class="intro">
<p>This example demonstrates how to respond to DOM events from a Node instance.</p>
<p>Clicking one of the elements will report some event details.</p>
</div>
<div class="example">
{{>events-source}}
</div>
<h2>Setting up the HTML</h2>
<p>First we need some HTML to work with.</p>
```
<div id="container">
<p>
<em>emphasis</em> <code>code</code> <strong>strong</strong> <a>anchor</a>
<img src="{{{componentAssets}}}/images/birds.png" align="middle"/>
</p>
</div>
<div id="event-result">Click an element above to see its event data.</div>
```
<h2>Creating the Event Handler</h2>
<p>Next we'll create a handler to run when the event is fired. In our handler
we'll update the `#event-result` node with some data available through the event.</p>
```
var onClick = function(e) {
var type = e.type,
currentTarget = e.currentTarget, // #container
target = e.target; // #container or a descendant
Y.one('#event-result').setContent('<dl>' +
'<dt>Event Type: </dt>' +
'<dd>' + e.type + '</dd>' +
'<dt>Target Tag Name: </dt>' +
'<dd>' + target.get('tagName') + '</dd>' +
'<dt>Color of Target's Font: </dt>' +
'<dd class="dd-color" style="background-color:' + target.getStyle('color') + ';">' + '</dd>' +
'<dt>CurrentTarget Tag Name & Id: </dt>' +
'<dd>' + currentTarget.get('tagName') + '#' + currentTarget.get('id') + '</dd>' +
'</dl>');
};
```
<h2>Listening for Events</h2>
<p>We can assign our handler to the container of the objects by using the `Y.one`.
Clicking on any object in the container will bubble the event to the container.
We're using the 'on' method to subscribe to the click and dblclick events.</p>
```
Y.one('#container').on('click', onClick);
Y.one('#container').on('dblclick', onClick);
```
<h2>Complete Example Source</h2>
```
{{>events-source}}
```