We can create a <var> element via the document.createElement()
method:
var x = document.createElement("VAR");
Click the button to create a VAR element with some text.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {// ww w . java 2 s . c o m var x = document.createElement("VAR"); var t = document.createTextNode("Some text.."); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>