Struggling on a for loop.. I cant seem to make it work..Trying to add a for loop to the (".circle" + (i+1)) Selector but not hiding and fading in one circle(i). Is this possible or some similar approach?
Any help would be appreciate it!
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<ul class="menu">
<li class="first"><a href="#btn1">btn1</a></li>
<li class="second"><a href="#btn2">btn2</a></li>
<li class="third"><a href="#btn3">btn3</a></li>
<li class="forth"><a href="#btn4">btn4</a></li>
</ul>
<div class="circle1 circle">1</div>
<div class="circle1 circle">2</div>
<div class="circle1 circle">3</div>
<div class="circle4 circle">4</div>
<script>
for(i=0;i<$(".menu li").length;i++){
$(".menu li").eq(i).on('click',function(){
$(".circle").hide();
$('.circle'+(i+1)).stop().fadeIn('300');
return false;
});
}
</script>
</body>
</html>
iis always equal to it's value at the end of the loop in your click handler.