Posted By

adamdecaf on 06/26/09


Tagged

html query selector 5


Versions (?)

JavaScript Query Selector


 / Published in: JavaScript
 

This will only work in FF 3.5 and web-kit browsers. (post 06/20/2009)

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. </head>
  6. <body>
  7.  
  8. <p id="hello">
  9.  
  10. </p>
  11.  
  12. <p class="goodbye">
  13.  
  14. </p>
  15.  
  16. <script>
  17. // Gather the elements
  18. var i = document.querySelector("p#hello");
  19. i.innerHTML = "Hello World";
  20.  
  21. var j = document.querySelector("p.goodbye");
  22. j.innerHTML = "Good Bye!";
  23. </script>
  24.  
  25. </body>
  26. </html>

Report this snippet  

You need to login to post a comment.