find id of element [closed]
Is there any way of determining the id attribute of any html element.
It's simple as pie:
var id = anyElement.id
The reverse function (determine element by id):
var anyElement = document.getElementById(id);
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);
精彩评论