V
V
Veteran Pupkov2021-07-06 21:05:18
HTML
Veteran Pupkov, 2021-07-06 21:05:18

How to remove a class from a block in js by clicking on the same block?

How to remove a class from a block by clicking on the same block next to it and add it to the one that was clicked last, on pure js, jquery is full of examples, I will be grateful

let blockClick = document.querySelectorAll('.item-layout')

for (var i = 0; i < blockClick.length; i++) {
    blockClick[i].addEventListener('click', function(e) {
        this.classList.add('active-bg');
    })
}


60e49b49a5495041898000.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Makarov, 2021-07-06
@jongallany

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question