Написал скрипт для выпадающего меню. Код работает коректно но очень большой. Объясните можно ли сделать тожесамое с помощю масива !
(function ret(){
var elem1 = document.getElementById("elementMenyu1");
var open1 = document.getElementById("openingBlock1");
var elem2 = document.getElementById("elementMenyu2");
var open2 = document.getElementById("openingBlock2");
var elem3 = document.getElementById("elementMenyu3");
var open3 = document.getElementById("openingBlock3");
var elem4 = document.getElementById("elementMenyu4");
var open4 = document.getElementById("openingBlock4");
var elem5 = document.getElementById("elementMenyu5");
var open5 = document.getElementById("openingBlock5");
var elem6 = document.getElementById("elementMenyu6");
var open6 = document.getElementById("openingBlock6");
var elem7 = document.getElementById("elementMenyu7");
var open7 = document.getElementById("openingBlock7");
var elem8 = document.getElementById("elementMenyu8");
var open8 = document.getElementById("openingBlock8");
elem1.onmouseover = function(){
open1.classList.add("heighters1");
};
elem1.onmouseout = function(){
open1.classList.remove("heighters1");
};
open1.onmouseover = function(){
open1.classList.add("heighters1");
};
open1.onmouseout = function(){
open1.classList.remove("heighters1");
};
elem2.onmouseover = function () {
open2.classList.add("heighters1");
};
elem2.onmouseout = function () {
open2.classList.remove("heighters1");
};
open2.onmouseover = function () {
open2.classList.add("heighters1");
};
open2.onmouseout = function () {
open2.classList.remove("heighters1");
};
elem3.onmouseover = function () {
open3.classList.add("heighters1");
};
elem3.onmouseout = function () {
open3.classList.remove("heighters1");
};
open3.onmouseover = function () {
open3.classList.add("heighters1");
};
open3.onmouseout = function () {
open3.classList.remove("heighters1");
};
elem4.onmouseover = function () {
open4.classList.add("heighters1");
};
elem4.onmouseout = function () {
open4.classList.remove("heighters1");
};
open4.onmouseover = function () {
open4.classList.add("heighters1");
};
open4.onmouseout = function () {
open4.classList.remove("heighters1");
};
elem5.onmouseover = function () {
open5.classList.add("heighters");
};
elem5.onmouseout = function () {
open5.classList.remove("heighters");
};
open5.onmouseover = function () {
open5.classList.add("heighters");
};
open5.onmouseout = function () {
open5.classList.remove("heighters");
};
elem6.onmouseover = function () {
open6.classList.add("heighters");
};
elem6.onmouseout = function () {
open6.classList.remove("heighters");
};
open6.onmouseover = function () {
open6.classList.add("heighters");
};
open6.onmouseout = function () {
open6.classList.remove("heighters");
};
elem7.onmouseover = function () {
open7.classList.add("heighters1");
};
elem7.onmouseout = function () {
open7.classList.remove("heighters1");
};
open7.onmouseover = function () {
open7.classList.add("heighters1");
};
open7.onmouseout = function () {
open7.classList.remove("heighters1");
};
elem8.onmouseover = function () {
open8.classList.add("heighters1");
};
elem8.onmouseout = function () {
open8.classList.remove("heighters1");
};
open8.onmouseover = function () {
open8.classList.add("heighters1");
};
open8.onmouseout = function () {
open8.classList.remove("heighters1");
};
})();