Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REUŻYWALNY KOMPONENT:
- =-=-=-=
- HTML
- =-=-=-=
- <nav>
- <div class="navbar">
- </div>
- </nav>
- =-=-=-=
- JS
- =-=-=-=
- 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>';
- let navbarElem = document.querySelector(".navbar");
- navbarElem.innerHTML = nav;
- ZMIANA KOLORU DIVA PO NACIŚNIĘCIU PRZYCISKU:
- =-=-=-=
- HTML
- =-=-=-=
- <button id="change-color-btn">Zmień kolor</button>
- <div id="my-div">To jest mój div</div>
- =-=-=-=
- JS
- =-=-=-=
- const changeColorBtn = document.getElementById("change-color-btn");
- const myDiv = document.getElementById("my-div");
- changeColorBtn.addEventListener("click", function() {
- myDiv.style.backgroundColor = "red";
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement