Advertisement
Rementai

reakt

Apr 13th, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. REUŻYWALNY KOMPONENT:
  2.  
  3. =-=-=-=
  4. HTML
  5. =-=-=-=
  6. <nav>
  7. <div class="navbar">
  8.  
  9. </div>
  10. </nav>
  11.  
  12. =-=-=-=
  13. JS
  14. =-=-=-=
  15.  
  16.  
  17. let nav = '<nav><ul><li><a href="index.html"> Home </a></li><li><a href="quiz.html"> Quiz </a></li><li><a href="map.html"> Mapa </a></li><li><a href="kontakt.html"> Kontakt </a></li><ul></nav>';
  18.  
  19. let navbarElem = document.querySelector(".navbar");
  20.  
  21. navbarElem.innerHTML = nav;
  22.  
  23.  
  24. ZMIANA KOLORU DIVA PO NACIŚNIĘCIU PRZYCISKU:
  25.  
  26. =-=-=-=
  27. HTML
  28. =-=-=-=
  29.  
  30. <button id="change-color-btn">Zmień kolor</button>
  31. <div id="my-div">To jest mój div</div>
  32.  
  33.  
  34. =-=-=-=
  35. JS
  36. =-=-=-=
  37.  
  38. const changeColorBtn = document.getElementById("change-color-btn");
  39. const myDiv = document.getElementById("my-div");
  40.  
  41. changeColorBtn.addEventListener("click", function() {
  42. myDiv.style.backgroundColor = "red";
  43. });
  44.  
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement