Get Variable Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Variable


The Variable object represents an HTML <var> element.

You can access a <var> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<var id="myVar">this text</var>

<button onclick="myFunction()">set the color</button>

function myFunction() {//w ww  .  j  av  a 2 s . c o m
    var x = document.getElementById("myVar"); = "red";


Related Tutorials