X
Publisher: Sigit purnomo kangsigit.com@gmail.com

Solutions for document.getElementsByTagName("body") Not Work

Some of the causes or issues that make document.getElementsByTagName('body') may not work properly is because there is something missing.

Yes, it is clear and usually people will write with getElementByTagName and not getElementsByTagName. It was natural because he probably has too often use similar code as getElementById so get carried away when using the tag name.

Forget the issue, because there are three characters are left to make the command incorrect. What three character? Here it is: [0]

Advertisement
Writing full code like this:
document.getElementsByTagName("body")[0].style.overflow="auto"
There are two records that you need to know that, in double quotation marks before and after the body will produce a focused display to the top of the page. Whereas if you use single quotation marks will bring the screen to the bottom of the page.

For the style.overflow="auto" you can set what you want to do. See you later..
no image
Add Comments
0 Comments
Click Here to Add Comments

No Comment