I have 3 “span”s
<span class="input1" style="display:block;"><span class="round"></span></span>
<span class="input2" style="display:none;"><span class="round"></span></span>
<span class="input3" style="display:none;"><span class="round"></span></span>
And this is the script:
$(document).ready(function() {
act = 1;
next = act+1;
});
$(".round").click(function (){
$('.input'+act).hide();
$('.input'+next).show();
act = next;
});
Push “.round” for the first time -> “.input1” – hide & “.input2” – show
If i want to push “.round” for the second time -> nothing happened. (This is the problem)
How to hide “.input2” and show “.input3”?
Thanks for help and sorry for my english!
Solution
Because
nextis always equal to 2.The second time,
act == 2andnext == 2so you hide then show the same element.Try that:
A bit of explanation
According to MDN:
++is a increment operator.