Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. #myDIV {
  6. border: 1px solid black;
  7. margin: 5px;
  8. }
  9. </style>
  10. </head>
  11. <body>
  12.  
  13. <div id="myDIV">
  14. <h3>A h3 element in div.</h3>
  15. <p>P element in div.</p>
  16. <span>A span element in div.</span>
  17. <h2>A h2 element in div.</h2>
  18. <div>A div element in div.</div>
  19. <p>Another p element in div.</p>
  20. </div>
  21. <div id="myDIV">
  22. <h3>A h3 element in div.</h3>
  23. <p>P element in div.</p>
  24. <span>A span element in div.</span>
  25. <h2>A h2 element in div.</h2>
  26. <div>A div element in div.</div>
  27. <p>Another p element in div.</p>
  28. </div>
  29.  
  30. <p>Click the button to add a background color to all elements inside the div element.</p>
  31.  
  32. <button onclick="myFunction()">Try it</button>
  33.  
  34. <script>
  35. function myFunction() {
  36. var x = document.getElementById("myDIV");
  37. var y = x.getElementsByTagName("p");
  38. var i;
  39. for (i = 0; i < y.length; i++) {
  40. y[i].style.backgroundColor = "red";
  41. }
  42. }
  43. </script>
  44.  
  45. <select name="condicion" onchange="myFunction(this.value)">
  46. <option value="1">PRESENTE</option>
  47. <option value="2">PERMISO</option>
  48. </select>
  49.  
  50. <select name="condicion" onchange="myFunction(this.value)">
  51. <option value="1">PRESENTE</option>
  52. <option value="2">PERMISO</option>
  53. </select>
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement