I'm having difficulties finding a solution for my problem. I have a collection of elements which have the same class name. They are all hidden and I have a button which should display the specific element. I can cycle trough all of the elements, but my code display ALL of them instead of only the one i clicked.
So I have to specify the current element which I want to change, maybe with "this"?
The usage of class names can be changed. Hope you can help me.
function checkDoublettesLAS() {
var doublettes = document.getElementsByClassName('checkSuccess');
for (var i = 0, n = doublettes.length; i < n; i++) {
$(doublettes[i]).css('display', 'block');
}
}
<div class="check">
<span class="checkSuccess" hidden>
foodummy1
</span>
<button onClick="checkDoublettesLAS();return false;">
Show Text
</button>
<span class="checkSuccess" hidden>
foodummy2
</span>
<button onClick="checkDoublettesLAS();return false;">
Show Text
</button>
<span class="checkSuccess" hidden>
foodummy3
</span>
<button onClick="checkDoublettesLAS();return false;">
Show Text
</button>
<span class="checkSuccess" hidden>
foodummy4
</span>
<button onClick="checkDoublettesLAS();return false;">
Show Text
</button>
<span class="checkSuccess" hidden>
foodummy5
</span>
<button onClick="checkDoublettesLAS();return false;">
Show Text
</button>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>