Chartjs-How to edit the ID of each button in a class if a condition is true in JavaScript?

0đź‘Ť

âś…

Lulian, inside of your for loop it looks like you are only changing the id’s of editbtns after the one that was deleted above. You may want to try taking out the if statement and replacing “newid” with “i”:

for (var i=0; i<editbuttons.length;i++) {
   // if (editbuttons[i].id>x) {
        editbuttons[i].id=i;
        //newid++;
        btnctr=i;
   // }
}

This way you can re-initialize all of you editbtn’s and btnctr to match from beginning to end.

Leave a comment