Posted By


fulvius on 12/04/10

Tagged


Statistics


Viewed 46 times
Favorited by 0 user(s)

insertAsFirstChild


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function insertAsFirstChild(parentNode, newChildNode){
  2. if(parentNode.hasChildNodes()){
  3. var refNode = parentNode.childNodes[0];
  4. parentNode.insertBefore(newChildNode, refNode);
  5. }else{
  6. parentNode.appendChild(newChildNode);
  7. }
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.