Skip to content

Commit

Permalink
DOM relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
estelle committed Apr 6, 2012
1 parent a86888e commit dbb6a87
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions part_06.html
Expand Up @@ -277,6 +277,29 @@ <h1>Changing Content</h1>
</div>


<div class="slide normal">
<header><h1>Add an element</h1></header>
<section class="content">
<ol>
<li>Create an element</li>
<li>Set attributes on that element</li>
<li>Create your textnode</li>
<li>Add content to that element by appending the textnode to the element you created</li>
<li>Targe the DOM node this new element will be next to</li>
<li>Add that node next to the the targeted node</li>
</ol>
<pre contenteditable>
var newLI = document.<strong>createElement</strong>('li');
newLI.<strong>setAttribute</strong>('class', 'myClass');
var textNode = document.<strong>createTextNode</strong>("some text");
newLI.<strong>appendChild</strong>(textNode);
var myUL = document.querySelector("#changeme ul");
myUL.appendChild(newLI);
</pre>
</section>
</div>





Expand Down

0 comments on commit dbb6a87

Please sign in to comment.