var d = document.createElement('div');
d.id = 'myElementId';
d.innerHTML = 'This is the content!';
Or
var d = document.createElement('div')
.id = 'myElementId';
.. same thing really, just a different way of laying it out.
This takes care of assigning the id. Now, for unique. The best way is to use the current time, as it isn't likely to repeat since javascript time is on miliseconds.
Putting it together:
var d = document.createElement('div')
.id = 'id'+new Date().getTime().toString();
This does have the chance to duplicate itself in the right circumstances. If it is is hyper-critical to maintain uniqueness, then the only way is to use a pointer:
// establish a variable to hold the pointer
var uniquePointer = 0;
// every time you use the pointer to create a new element, increment the pointer.
var d = document.createElement('div')
.id = 'id'+uniquePointer;
uniquePointer ++;