Hi richardkwright,
No, you can’t assign an ID to an object: they are assigned exclusively by InDesign. But you can get and use them (I mean the IDes of such objects as text frames, rectangles, etc. in InDesign. I am sure you can't get/set the IDes of DIVes in the exported HTML).
Here’s my idea (off the top of my head):
To illustrate it let’s run this script ...
main();
function main() {
var textFrame, recrangle, objExpOptions,
doc = app.activeDocument,
textFrames = doc.textFrames,
rectangles = doc.rectangles;
for (var i = 0; i < textFrames.length; i++) {
textFrame = textFrames;
textFrame.insertionPoints[0].contents = "[" + textFrame.id + "]";
}
for (var j = 0; j < rectangles.length; j++) {
recrangle = rectangles;
objExpOptions = recrangle.objectExportOptions;
objExpOptions.altTextSourceType = SourceType.SOURCE_CUSTOM;
objExpOptions.customAltText = "[" + recrangle.id + "]";
}
}
... against this sample document — Test-Before.indd (created in InDesign CC2014) — consisting of three text frames and three linked images.

After running the script visually nothing is changed. However, the script loops through every text frame, reads its unique ID and adds it enclosed in square brackets at the beginning of the text.

The text is invisible because I applied a character style via GREP style.
The character style has text size — 0.1 pt ...

... and text color – “Paper” – which makes it unseen.

GREP style applies it to any number of digits between square brackets at the beginning of a line.

With images I use a little different approach: I get the ID of each container (let’s assume the images are always placed in rectangles) and write it as custom “Alt Text” in object export options.

After I export the document to HTML, visually nothing is changed as well, but in the source view you can see the IDes square brackets like so:

Hope this helps.
Kasyan