sorting problem, resort the div id after sort
hi everybody!!
im sorry for disturbing you!
im learning jquery at the moment (and english ...*g*, no clue where i suck more...)
and now ive got following problem:
i make use of the jquery ui and there specially i use the sortable thingy...
so now the problem:
im trying to sort some divs. after sorting i want to sort the order of the divs in a new way (simple from 0 - x).
so far my code looks like that:
-
$('#sort').sortable({
placeholder: 'placeHolder',
handle: '.handle',
update: function(event, ui) {
var divArray = $(this).sortable("toArray");
for (var i = 0; i < divArray.length; i++) {
//do something
}
}
});
i want that on update the function sort the divs from 0 - x. therefore i need the $('#div').attr('id', ...) function. maybe in combination with the function first. but dunno how...
can someone help me?
practical example:
id=div 1 text=1
id=div 2 text=2
id=div 3 text=3
after sorting its like that
div 2 text=2
div 1 text=1
div 3 text=3
but then i want a function that makes
div 1 text=2
div 2 text=1
div 3 text=3
again. so the div id should be ordered normally by 0 - x. but the content of the divs should stay as they were after the sort.
i hope u can help me ...and u can understand me! ;-P i tryed my best but my english sucks!
greetings