Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
.button-subcatalog { position: absolute; top: -10px; left: 243px; z-index: 3; width: 50px; height: 50px; border-radius: 50%; background-color: transparent; border: 2px solid #000000; opacity: 0.3; } .button-subcatalog-opened { background-image: url("../images/header/plus-icon.svg"); background-size: 16px 16px; background-repeat: no-repeat; background-position: center; } .button-subcatalog-closed { background-image: url("../images/header/minus-icon.svg"); background-size: 16px 2px; background-repeat: no-repeat; background-position: center; } .catalog-closed .catalog-popover-wrapper, .catalog-closed .button-subcatalog-opened { display: none; } .catalog-open .button-subcatalog-closed { display: block; }
<li class="navigation-catalog-item catalog-closed"> <a class="navigation-link" href="catalog.html">КАТАЛОГ ТОВАРОВ</a> <button class="button-subcatalog button-subcatalog-open" type="button"> <span class="visually-hidden">Подменю.</span> </button> <div class="catalog-popover-wrapper catalog-closed-nojs"> <ul class="subcatalog-list"> <li class="subcatalog-item">
let catalogItem = document.querySelector('.navigation-catalog-item'); let buttonSubcatalog = document.querySelector('.button-subcatalog'); catalogItem.classList.remove('catalog-closed-nojs'); buttonSubcatalog.addEventListener('click', function () { if (catalogItem.classList.contains('catalog-closed')) { catalogItem.classList.remove('catalog-closed'); catalogItem.classList.add('catalog-opened'); } else { catalogItem.classList.add('catalog-closed'); catalogItem.classList.remove('catalog-opened'); } });