node-insert.mustache revision fb1ecdf65fd4106deb62da339763f2e7670ca0f6
2N/A <p>This example demonstrates how insert content when working with <code>NodeList</code> instances.</p>
2N/A<p>Next we will add a handler to run when the event is fired. In our handler we will add content to the node.</p>
2N/A<p>Note that the event handler receives an event object with its <code>currentTarget</code> set to the current Node instance, and the actual node clicked as the <code>target</code>. The context of the handler is the NodeList instance, so <code>this</code> refers to our NodeList instance.</p>
2N/A<p>Note also that <code>prepend</code> inserts content as the <code>firstChild</code> of the Node instance, <code>append</code> inserts content as the <code>lastChild</code>, and <code>insert</code> places content before the specified node or childNode index.</p>
2N/A var node = e.currentTarget;
2N/A node.prepend('<em>prepended</em> '); // added as firstChild
2N/A node.append(' <em>appended</em>'); // added as lastChild
2N/A node.insert(' <strong>before last child</strong> ', node.get('lastChild')); // added before lastChild
2N/A node.insert(' <strong>before childNodes[1]</strong> ', 1); // added before childNodes[1]