Create an Aside Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Aside

Introduction

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">create an ASIDE element containing a H4</button>

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

    var heading = document.createElement("H4");
    var txt1 = document.createTextNode("header in aside");
    heading.appendChild(txt1);
    document.getElementById("myAside").appendChild(heading);

}
</script>

</body>
</html>

Related Tutorials