Javascript DOM - Create Element

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

Basic create element and append it too another element.

Copy this code and paste it in your HTML
  1. var root = document.getElementById("root");
  3. var a = document.createElement("a");
  4. a.setAttribute("href", "");
  5. a.setAttribute("title", "Foo Bar");
  7. root.appendChild(a);

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.