пример более сложный, но суть та же - меняется DOM
function reOrder(tid) {
var x=document.getElementById(tid).tBodies[0];
var count = 1;
Array.prototype.forEach.call(x.rows, function(el) {
if (el.hasAttribute('id')) {
el.setAttribute('id',count);
if (el.children[4].children[2].hasAttribute('onclick')) {
var oldval = el.children[4].children[2].getAttribute('onclick');
var newval = oldval.replace(/\d+/g, count);
el.children[4].children[2].setAttribute('onclick', newval);
}
count++;
}
});
}