I suggest you edit your question to represent accurately what you are looking for.
Based on your comments, if you are looking for the FIRST DIV, use something like this:-
x=document.getElementsByTagName("div");
if (x!= 'undefined' && x.length > 0 )
document.write(x[0].id);
2
solved find id of element [closed]