New course! Every coder should learn Generative AI!
Try a free lesson+ 4
document.getElementsByTagName() returns a collection of elements like an array not a single element. You need to select it's contents as you do in an array like:
--------
var elems = document.getElemenetsByTagName('body');
elems[0]; // First body element.
--------
**********
Use document.body to select the body element.
+ 3
For accessing body element, use document.body
To set background color of body
document.body.style.background = 'black';
+ 2
Can you please post the code here?