Given the following:
<a id="moveElementUp">Move Up</a>
<a id="moveElementDown">Move Dowm</a>
<div id="elementHolder">
<a id="element-1">1</a>
<a id="element-2">2</a>
<a id="element-3">3</a>
<a id="element-4">4</a>
</div>
<script type="text/javascript">
function reOrder (el){
// Change IDs of Elements to be Sequential
}
$('#moveElementUp').click(function(e){
// Move Clicked Element Up One Spot in List
reOrder();
});
$('#moveElementDown').click(function(e){
// Move Clicked Element Down One Spot in List
reOrder();
});
</script>
What is the optimal (and fastest) way of going about changing the order of the elements and changing the IDs of all elements to maintain sequential order using jQuery?
Any help would be greatly appreciated!