1
I have several buttons with data-numBtn numeric and with value equal to that of div (with attribute data-slide) that controls. In short, I’d like to click e.g. on .btn with data-numBtn="3" something happens (eg fadein) to .img with data-slide="3" also. PS: The elements will be loaded dynamically, without sight of how many will be, the 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>
Since you’re not doing any other operation with numBtn could remove it and use directly on selector (first code) or jQuery.eq() (second)
– Bruno Augusto
@Brunoaugusto true. As it suggests would be smaller the code. I left so to be clearer, step by step.
– Sergio