Create a Footer Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Footer

Introduction

You can create a <footer> element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">create a FOOTER element containing a P element with some text</button>

<script>
function myFunction() {//  ww w . j a  v  a  2  s.  c  o m
    var x = document.createElement("FOOTER");
    x.setAttribute("id", "myFooter");
    document.body.appendChild(x);

    var y = document.createElement("P"); 
    var t = document.createTextNode("This is a p element in a footer element.");
    y.appendChild(t);

    document.getElementById("myFooter").appendChild(y);
}
</script>

</body>
</html>

Related Tutorials