Technically, this isn't for a 'list' (ul -> li), but for a series of div
blocks inside a container div
. I have tried many different ways to try and achieve this, but none of them work. What happens is that when I get to the last element, and then click on my 'next button' it takes me to the SECOND element in the list, never the first element. This is generally the code I'm using:
<div class="wrapperClass">
<div class="myClass" id="ID1">
<div class="anotherClass">
<input value="myValue1"/>
</div>
</div>
<div class="myClass" id="ID2">
<div class="anotherClass">
<input value="myValue2"/>
</div>
</div>
<div class="myClass" id="ID3">
<div class="anotherClass"">
<input value="myValue3"/>
</div>
</div>
...
</div>
and
var nextID = $('div#'+ID).next().find('input').val();
var lastID = $('div#'+ID+':last').find('input').val();
if( nextID == lastID )
{
nextID = $('.wrapperClass').find('input:first').val();
}
// other code