To answer your doubt, ID is an attribute, which you can set with the attr function:
$(element).attr('id', 'newID');
I am not too certain with what you mean by adding IDs because a given element can only have a single identifier which must be unique as a condition. I'm not sure what you mean about adding IDs since an element can only have one identifier and this identifier must be unique.