Get a HTML element without getElementById - Javascript DOM

Javascript examples for DOM:Document getElementById

Description

Get a HTML element without getElementById

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
    // set a global var to acces the elements in the HTML document
    var doc = this;//from   w w w.  jav  a  2s.c  o  m
    function testIt()
    {
        doc.blaat.innerHTML = 'It works!!';
    }

      </script> 
   </head> 
   <body> 
      <div id="blaat">
         Will this ever work..?!
      </div> 
      <button onclick="testIt()">Click me and you'll see!</button>  
   </body>
</html>

Related Tutorials