Create a Variable Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Variable


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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

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

function myFunction() {//from   w w  w.  ja va m
    var x = document.createElement("VAR");
    var t = document.createTextNode("Some text..");


Related Tutorials