F
F
Flagname2020-04-23 17:47:26
JavaScript
Flagname, 2020-04-23 17:47:26

How can I make sure that when clicking on each of the blocks, its own content appears?

There are several divs. Their number can be any, not fixed. It is necessary that when you click on each of the divs, its content gets out. Each has its own content. How to implement this? I understand that the analogy is with tabs, but I can’t think of it on my own.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tigran Abrahamyan, 2020-04-23
@Flagname

E
Eugene, 2020-04-23
@Kasperenysh

div * {opasity: 0;}

let parentElement = document.querySelector('div').parentNode;
parentElement.addEventListener('click', function (e) {
    let elemArr = e.target.children;
    for(let i = 0; i < elemArr.lenght; i++) {
        elemArr[i].style.opasity = '1';
    }
});

Since there are no options, then without changing the document - this is such an option, but I advise you to make an intermediate div, and only hang the style for it))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question