SHARE
TWEET

Untitled

a guest Feb 14th, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let pictures = ["dounat-1", "dounat-2", "dounat-3", "dounat-4", "dounat-5", "dounat-6"];
  2.  
  3. let container = document.getElementsByClassName("container__item-second")
  4.  
  5. let fir = document.getElementById("1");
  6. let sec = document.getElementById("2");
  7. let thi = document.getElementById("3");
  8. let fort = document.getElementById("4");
  9. let fif = document.getElementById("5");
  10. let six = document.getElementById("6");
  11.  
  12. fir.addEventListener("click", function(){changeButton(document.getElementById('7'), document.getElementById('13'),pictures[0])});
  13. sec.addEventListener("click", function(){changeButton(document.getElementById('8'), document.getElementById('14'), pictures[1])});
  14. thi.addEventListener("click", function(){changeButton(document.getElementById('9'), document.getElementById('15'), pictures[2])})
  15. fort.addEventListener("click", function(){changeButton(document.getElementById('10'), document.getElementById('16'), pictures[3])})
  16. fif.addEventListener("click", function(){changeButton(document.getElementById('11'), document.getElementById('17'), pictures[4])})
  17. six.addEventListener("click", function(){changeButton(document.getElementById('12'), document.getElementById('18'), pictures[5])})
  18.  
  19.  
  20. function changeButton(idImg, idParagraf, img){
  21.  
  22.     if (idImg.getAttribute("src")=="img/donut.png")
  23.         {
  24.             idImg.src='img/'+ img +'.jpg'
  25.             idParagraf.className="container__item-third__visible"  
  26.            // let sib = this.nextElementSibling
  27.             //sib.src="img/donut.png"
  28.                
  29.         }
  30.         else
  31.         {  
  32.             idImg.src='img/donut.png'
  33.             idParagraf.setAttribute("class","container__item-third")
  34.            
  35.         }
  36.  
  37.  
  38.  
  39. }
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