toggle class for each item with only one function
Hi !
I have many boxes with same class :
- <img data-id="1" src="showhide.svg"/><div data-id="1" class="box"></div>
- <img data-id="2" src="showhide.svg"/><div data-id="2" class="box"></div>
- <img data-id="2" src="showhide.svg"/><div data-id="3" class="box"></div>
When I click on one img I want to toggle class for the box with the same data-id (no idea how many boxes I have and what data-id it is)
to get :
- <img data-id="1" src="showhide.svg"/><div data-id="1" class="box expand"></div>
if I click a second time expand should be removed:
- <img data-id="1" src="showhide.svg"/><div data-id="1" class="box"></div>
thanks for helping