Im using jquery to move divs either up or down, which is part of a ranking system, so I need the ranking classes to stay the same depending on whether the div is either first, second, third and so on... The top div should always have class first, second div class equals second etc etc... Any help much appr.
html:
<div class="top5 first">
<div class="voter">
<a class="up" href="#">up</a>
<a class="down" href="#">down</a>
</div>
</div>
<div class="top5 second">
<div class="voter">
<a class="up" href="#">up</a>
<a class="down" href="#">down</a>
</div>
</div>
<div class="top5 third">
<div class="voter">
<a class="up" href="#">up</a>
<a class="down" href="#">down</a>
</div>
</div>
jquery:
$('.up').click(function() {
var parent = $(this).parent().parent();
parent.insertBefore(parent.prev());
});
$('.down').click(function() {
var parent = $(this).parent().parent();
parent.insertAfter(parent.next());
});