Javascript examples for DOM HTML Element:Div
Toggle div element background colour
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> #demo {//from w w w . j a v a 2s. co m font-family: monospace; } </style> <script type="text/javascript"> window.onload=function(){ var div = document.querySelector('#demo'); div.style.background = 'rgb(255,0,0)'; div.innerText = div.style.background; } </script> </head> <body> <div id="demo"></div> </body> </html>