Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. console.log("podłoczone"); //podłączone xd
  2. //na początku dodaj atrybut data-num (numeracja od 0) i klasę 'question' do każdego elementu
  3.  
  4. const answer = document.getElementById("answer");
  5. // answerFunction(1) zamiast tego wpisz domyślny stan w HTMLu, a później będzie on zmieniany przez JSa
  6.  
  7. let questions = document.querySelectorAll('.question');
  8. questions.forEach((x)=> x.addEventListener('mousemove', function(e){
  9. const attribute = e.target;
  10. switch (attribute.getAttribute('data-num')) {
  11. case '0':
  12. attribute.innerHTML = "Long established fact that a reader will be of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. many web sites still in their infancy. Various versions have evolved. sometimes by accident, sometimes on purpose (injected humour and the like).";
  13. check("quest-one");
  14. break;
  15. case '1':
  16. attribute.innerHTML = "Long established fact that a reader will be distracted by the readable content";
  17. check("quest-two");
  18. break;
  19. case '2':
  20. attribute.innerHTML = "change 3";
  21. check("quest-three");
  22. break;
  23. case '3':
  24. attribute.innerHTML = "ok";
  25. check("quest-four");
  26. break;
  27. case '4':
  28. attribute.innerHTML = "no";
  29. check("quest-five");
  30. break;
  31. case '5':
  32. attribute.innerHTML = "hello world";
  33. check("quest-six");
  34. break;
  35. }
  36. },false));
  37.  
  38. function check(add){
  39. document.getElementById(add).classList.add('quest-active');
  40. questions.forEach(function(x){if(x.id != 'add'){x.classList.remove('quest-active')}});
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement