Задать вопрос
  • Как это лучше запрограммировать?

    @slavaweb Автор вопроса
    все это конечно круто но я имел в виду используя этот код который есть и те методы которые в нем
  • Как это лучше запрограммировать?

    @slavaweb Автор вопроса
    спасибо, но то что вы написали я не пойму по ссылки в редакторе js ничего не написано
  • Как это лучше запрограммировать?

    @slavaweb Автор вопроса
    var toggle = document.querySelectorAll(".faq__accordion-toggle");
    var answer = document.querySelectorAll(".faq__accordion-answer");

    toggle[0].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[0].classList.contains("faq__item-answer-show")) {
    answer[0].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.add("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[1].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[1].classList.contains("faq__item-answer-show")) {
    answer[1].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.add("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[2].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[2].classList.contains("faq__item-answer-show")) {
    answer[2].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.add("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[3].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[3].classList.contains("faq__item-answer-show")) {
    answer[3].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.add("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[4].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[4].classList.contains("faq__item-answer-show")) {
    answer[4].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.add("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[5].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[5].classList.contains("faq__item-answer-show")) {
    answer[5].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.add("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[6].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[6].classList.contains("faq__item-answer-show")) {
    answer[6].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.add("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[7].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[7].classList.contains("faq__item-answer-show")) {
    answer[7].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.add("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[8].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[8].classList.contains("faq__item-answer-show")) {
    answer[8].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.add("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[9].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[9].classList.contains("faq__item-answer-show")) {
    answer[9].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.add("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[10].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[10].classList.contains("faq__item-answer-show")) {
    answer[10].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.add("faq__item-answer-show");
    answer[11].classList.remove("faq__item-answer-show");
    }
    });
    toggle[11].addEventListener("click", function (event){
    event.preventDefault();
    console.log("Клик по ссылки");
    if (answer[11].classList.contains("faq__item-answer-show")) {
    answer[11].classList.remove("faq__item-answer-show");
    }
    else {
    answer[0].classList.remove("faq__item-answer-show");
    answer[1].classList.remove("faq__item-answer-show");
    answer[2].classList.remove("faq__item-answer-show");
    answer[3].classList.remove("faq__item-answer-show");
    answer[4].classList.remove("faq__item-answer-show");
    answer[5].classList.remove("faq__item-answer-show");
    answer[6].classList.remove("faq__item-answer-show");
    answer[7].classList.remove("faq__item-answer-show");
    answer[8].classList.remove("faq__item-answer-show");
    answer[9].classList.remove("faq__item-answer-show");
    answer[10].classList.remove("faq__item-answer-show");
    answer[11].classList.add("faq__item-answer-show");
    }
    });
  • Не понятно куда запушились коммиты в гите???

    @slavaweb Автор вопроса
    Отобразились, спустя час. Все ок.