I'm hoping someone can help the brain freeze I've had in the past couple of hours. I am using the below code to create a text node and a span element.
I can't really style a text element directly inside a DIV without some kind of mark-up so I am trying to make the DOM create nodes in this orderCode:onload=function(){ var root = document.getElementById('zonediv'); for(var i=0;i<D.length;i++){ root.appendChild(document.createTextNode(D[i][0]+' ')) var sp= document.createElement('span'); sp.appendChild(document.createTextNode(' ')); root.appendChild(sp);root.appendChild(document.createElement('br')) }
I know it's probably easy, my brain just won't register at this time of night... so thanks in advance.Code:<div id="zonediv"> // parent <p> // need to replace text node with p element <span> <br>



Reply With Quote


Bookmarks