Advertisement
morpe

getElementById e innerHTML

Jan 22nd, 2011
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>Primo JS</title>
  6.  
  7. <script type="text/javascript" >
  8.  
  9.     function miao(){
  10.         var massi = document.getElementById("test").innerHTML;
  11.         //alert(massi);
  12.        
  13.         test.innerHTML = "<h1>FUNZIONAAAAAA!!!</h1>";
  14.        
  15.     }
  16.  
  17. </script>
  18.  
  19. </head>
  20.  
  21. <body>
  22. <div style="text-align: center;" ><br><br>
  23.     Funzione che usa: getElementById e innerHTML per modificare il contenuto del div con id: test
  24.     clicando <span id="test" onclick="miao()"><b>QUI</b></span>, il testo cambia!
  25. </div>
  26.  
  27.  
  28.  
  29. </body>
  30. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement