var element = document.getElementsByTagName("div")[0];
var id = element.id;
$(this).attr('id'); // for id
$(this).attr('class'); // for class
// this can be any element you have obtained
async function test (){
document.body.innerHTML = await "<foo id='successGetID'>Hello Wolrd</foo>";
var init = await document.getElementsByTagName("foo")[0].id;
alert( init );
}
test();