Javascript examples for Language Basics:Introduction
Run code before the DOM is fully loaded
<html> <head> <style type="text/css"> .foobar { background-color: #CCC; } </style> </head> <body> <script type="text/javascript"> window.document.body.className = "foobar"; /* w w w .j a v a 2 s.c om*/ </script> <div style="border: solid 1px"> <br> </div> <script type="text/javascript"> console.log("happens before DOM is fully loaded"); console.log(window.document.body.className); </script> <span>Appears after the console.log() call.</span> </body> </html>