SHARE
TWEET

Untitled

a guest Feb 15th, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let pictures = [
  2.   "dounat-1",
  3.   "dounat-2",
  4.   "dounat-3",
  5.   "dounat-4",
  6.   "dounat-5",
  7.   "dounat-6"
  8. ];
  9.  
  10. let container = document.getElementsByClassName("container__item-second");
  11. let third = document.querySelectorAll(".container__item-third");
  12.  
  13. let fir = document.getElementById("1");
  14. let sec = document.getElementById("2");
  15. let thi = document.getElementById("3");
  16. let fort = document.getElementById("4");
  17. let fif = document.getElementById("5");
  18. let six = document.getElementById("6");
  19.  
  20. fir.addEventListener("click", function() {
  21.   changeButton(
  22.     document.getElementById("7"),
  23.     document.getElementById("13"),
  24.     pictures[0]
  25.   );
  26. });
  27. sec.addEventListener("click", function() {
  28.   changeButton(
  29.     document.getElementById("8"),
  30.     document.getElementById("14"),
  31.     pictures[1]
  32.   );
  33. });
  34. thi.addEventListener("click", function() {
  35.   changeButton(
  36.     document.getElementById("9"),
  37.     document.getElementById("15"),
  38.     pictures[2]
  39.   );
  40. });
  41. fort.addEventListener("click", function() {
  42.   changeButton(
  43.     document.getElementById("10"),
  44.     document.getElementById("16"),
  45.     pictures[3]
  46.   );
  47. });
  48. fif.addEventListener("click", function() {
  49.   changeButton(
  50.     document.getElementById("11"),
  51.     document.getElementById("17"),
  52.     pictures[4]
  53.   );
  54. });
  55. six.addEventListener("click", function() {
  56.   changeButton(
  57.     document.getElementById("12"),
  58.     document.getElementById("18"),
  59.     pictures[5]
  60.   );
  61. });
  62.  
  63. function changeButton(idImg, idParagraf, img) {
  64.   if (idImg.getAttribute("src") == "img/donut.png") {
  65.     for (let i = 0; i < third.length; i++) {
  66.       console.log(third[i].className);
  67.  
  68.       third[i].style = "display: none";
  69.     }
  70.     idImg.src = "img/" + img + ".jpg";
  71.     idParagraf.style = "display: block";
  72.     idParagraf.className = "container__item-third__visible";
  73.  
  74.     // let sib = this.nextElementSibling
  75.     //sib.src="img/donut.png"
  76.   } else {
  77.     idImg.src = "img/donut.png";
  78.     idParagraf.setAttribute("class", "container__item-third");
  79.   }
  80. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top