I have several buttons with data-numBtn
numeric and with value equal to the div (with data-slide
attribute) that it controls. In short, I liked that when I clicked for ex: .btn
with data-numBtn="3"
something happens (eg fadeIn) to .img
with data-slide="3"
as well. PS: Elements will be dynamically loaded, no matter how many they will be, elements data-numBtn
and data-slide
will always match.
HTML:
<div class="btn" data-numBtn="1">...</div>
<div class="btn" data-numBtn="2">...</div>
<div class="btn" data-numBtn="3">...</div>
<div class="btn" data-numBtn="4">...</div>
<div class="img" data-slide="1">...</div>
<div class="img" data-slide="2">...</div>
<div class="img" data-slide="3">...</div>
<div class="img" data-slide="4">...</div>