So the code below will get the ID of the BODY elementL
var bodyId = document.body.id;
How can I get the ID of the HTML element using plain ole' JavaScript?
So the code below will get the ID of the BODY elementL
var bodyId = document.body.id;
How can I get the ID of the HTML element using plain ole' JavaScript?
Share Improve this question asked Jul 14, 2011 at 2:19 CofeyCofey 11.4k16 gold badges54 silver badges75 bronze badges 3 |2 Answers
Reset to default 12document.documentElement.id
document.getElementsByTagName('HTML')[0].id
body
element. The OP wants the ID of thehtml
element. – icktoofay Commented Jul 14, 2011 at 2:21