Posted By

jasonseney on 03/19/10


Tagged

javascript DOM


Versions (?)

Javascript DOM - Create Element


 / Published in: JavaScript
 

Basic create element and append it too another element.

  1. var root = document.getElementById("root");
  2.  
  3. var a = document.createElement("a");
  4. a.setAttribute("href", "http://foobar.com");
  5. a.setAttribute("title", "Foo Bar");
  6.  
  7. root.appendChild(a);

Report this snippet  

You need to login to post a comment.