Answer the question
In order to leave comments, you need to log in
How to add a class to all blocks that are displayed after the 3rd block?
How to add a class to all blocks that are displayed after the 3rd block?
for example , after the 3rd block, the green class should be substituted for all the rest
Answer the question
In order to leave comments, you need to log in
If parent is common:
document
.querySelectorAll('.service:nth-child(n + 5)')
.forEach(n => n.classList.add('green'));
Array
.from(document.querySelectorAll('.service'))
.slice(4)
.forEach(n => n.classList.add('green'));
You can simply style:
.container div:nth-child(n + 4){
border:1px solid green;
background-color:lightgreen;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question