Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>My favorite colors</title>
  5. <link rel="stylesheet" href="style.css">
  6. <script src="rectangles.js">
  7. <meta charset="utf-8">
  8. </head>
  9. <body>
  10. <h1>My favorite colors</h1>
  11. <h2>Some of my favorite colors are displayed below</h2>
  12. <div id="rectangleWrapper">
  13. <div class="rect" id="first"><span>#FFD433</span></div>
  14. <div class="rect" id="second"><span>#4CFF33</span></div>
  15. <div class="rect" id="third"><span>#33FFEC</span></div>
  16. <div class="rect" id="fourth"><span>#339CFF</span></div>
  17. <div class="rect" id="fifth"><span>#3342FF</span></div>
  18. <div class="rect" id="sixth"><span>#FF4633</span></div>
  19. <div class="rect" id="seventh"><span>#B833FF</span></div>
  20. <div class="rect" id="eighth"><span>#FF33B8</span></div>
  21. <div class="rect" id="nineth"><span>#FF336E</span></div>
  22. <div class="rect" id="tenth"><span>#FF7A33</span></div>
  23. </div>
  24. <script>
  25. window.onload = () => {
  26. let rects = document.querySelectorAll('.rect');
  27. let result = '';
  28. for(rect of rects) {
  29. result += rect.id + ', ';
  30.  
  31. }
  32. if(result[result.length-2] === ',') {
  33. result = ' ' + result.substr(0,result.length - 2)
  34. }
  35. console.log("Here are the rectangle IDs:" + result + '.')
  36. }
  37. </script>
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement