Javascript examples for DOM HTML Element:Variable
The Variable object represents an HTML <var> element.
You can access a <var> element by using getElementById():
<!DOCTYPE html> <html> <body> <var id="myVar">this text</var> <button onclick="myFunction()">set the color</button> <script> function myFunction() {//w ww . j av a 2 s . c o m var x = document.getElementById("myVar"); x.style.color = "red"; } </script> </body> </html>