Skip to content
Advertisement

Close other div when new div is opened (in forloop.counter)

I am trying to close the other div when I open a new div, But I am using in loop so I used forloop.counter But it is not working. And when I try to use without forloop.counter or outside the loop then it is working fine, but I want to use inside the for loop.

page.html

JavaScript

I have also tried using forEach like :-

JavaScript

but it is not working and it is not showing any error.

What I am trying to do?

I am trying to close active div when new div is open in for loop.

I have tried many times but it didn’t work. I seen many questions, but unfortunately I didn’t find any of them for forloop.counter. Any help would be much Appreciated. Thank You in Advance.

Advertisement

Answer

You can do it like this (if forloop.counter works without problem):

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement