Web page of meissner-wohnen.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.2 KiB

  1. (function() {
  2. var wohnung = document.querySelectorAll(".wohnung-img"),
  3. kueche = document.querySelectorAll(".kueche-img"),
  4. bad = document.querySelectorAll(".bad-img"),
  5. index = 0;
  6. var setActive = function (element) {
  7. if(document.getElementById(element).classList) {
  8. document.getElementById(element).classList.add("active");
  9. } else {
  10. document.getElementById(element).setAttribute("class", "active");
  11. }
  12. };
  13. var setDeactive = function (element) {
  14. if(document.getElementById(element).classList) {
  15. document.getElementById(element).classList.remove("active");
  16. } else {
  17. document.getElementById(element).removeAttribute("class");
  18. }
  19. };
  20. for (index=0; index <= wohnung.length-1; index++) {
  21. if (wohnung[index].addEventListener) {
  22. wohnung[index].addEventListener("mouseenter", function(){setActive("wohnung")}, false);
  23. wohnung[index].addEventListener("mouseleave", function(){setDeactive("wohnung")}, false);
  24. } else {
  25. wohnung[index].attachEvent("onmouseenter", function(){setActive("wohnung")});
  26. wohnung[index].attachEvent("onmouseleave", function(){setDeactive("wohnung")});
  27. }
  28. }
  29. for (index=0; index <= kueche.length-1; index++) {
  30. if (kueche[index].addEventListener) {
  31. kueche[index].addEventListener("mouseenter", function(){setActive("kueche")}, false);
  32. kueche[index].addEventListener("mouseleave", function(){setDeactive("kueche")}, false);
  33. } else {
  34. kueche[index].attachEvent("onmouseenter", function(){setActive("kueche")});
  35. kueche[index].attachEvent("onmouseleave", function(){setDeactive("kueche")});
  36. }
  37. }
  38. for (index=0; index <= bad.length-1; index++) {
  39. if (bad[index].addEventListener) {
  40. bad[index].addEventListener("mouseenter", function(){setActive("bad")}, false);
  41. bad[index].addEventListener("mouseleave", function(){setDeactive("bad")}, false);
  42. } else {
  43. bad[index].attachEvent("onmouseenter", function(){setActive("bad")});
  44. bad[index].attachEvent("onmouseleave", function(){setDeactive("bad")});
  45. }
  46. }
  47. }());