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.

58 lines
2.3 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. // add class 'active' to the element
  7. var setActive = function (element) {
  8. if(document.getElementById(element).classList) {
  9. document.getElementById(element).classList.add("active");
  10. } else {
  11. document.getElementById(element).setAttribute("class", "active");
  12. }
  13. };
  14. // remove class 'active' from element
  15. var setDeactive = function (element) {
  16. if(document.getElementById(element).classList) {
  17. document.getElementById(element).classList.remove("active");
  18. } else {
  19. document.getElementById(element).removeAttribute("class");
  20. }
  21. };
  22. for (index=0; index <= wohnung.length-1; index++) {
  23. if (wohnung[index].addEventListener) {
  24. wohnung[index].addEventListener("mouseenter", function(){setActive("wohnung")}, false);
  25. wohnung[index].addEventListener("mouseleave", function(){setDeactive("wohnung")}, false);
  26. } else {
  27. wohnung[index].attachEvent("onmouseenter", function(){setActive("wohnung")});
  28. wohnung[index].attachEvent("onmouseleave", function(){setDeactive("wohnung")});
  29. }
  30. }
  31. for (index=0; index <= kueche.length-1; index++) {
  32. if (kueche[index].addEventListener) {
  33. kueche[index].addEventListener("mouseenter", function(){setActive("kueche")}, false);
  34. kueche[index].addEventListener("mouseleave", function(){setDeactive("kueche")}, false);
  35. } else {
  36. kueche[index].attachEvent("onmouseenter", function(){setActive("kueche")});
  37. kueche[index].attachEvent("onmouseleave", function(){setDeactive("kueche")});
  38. }
  39. }
  40. for (index=0; index <= bad.length-1; index++) {
  41. if (bad[index].addEventListener) {
  42. bad[index].addEventListener("mouseenter", function(){setActive("bad")}, false);
  43. bad[index].addEventListener("mouseleave", function(){setDeactive("bad")}, false);
  44. } else {
  45. bad[index].attachEvent("onmouseenter", function(){setActive("bad")});
  46. bad[index].attachEvent("onmouseleave", function(){setDeactive("bad")});
  47. }
  48. }
  49. }());