Track Div 0.0
by Paul Schmitt
HTML
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<div id="a1"></div>
<div id="a2"></div>
<div id="a3"></div>
<div id="a4"></div>
<p>
<button id="prev">Go to Prev</button>
</p>
<p>
<button class="next">Go to Next</button>
</p>
CSS
div {
width: 40px;
height: 40px;
margin: 10px;
float: left;
border: 2px blue solid;
padding: 2px;
}
p {
clear: left;
margin: 10px;
}
#start {}
JavaScript
var $curr = $("#a1");
$curr.css("background", "#f99");
$("button, .next").click(function () {
$curr = $curr.next();
$("div").css("background", "");
$curr.css("background", "#f99");
});