简体   繁体   中英

How do I change the css overflow property of the HTML with javascript

at the moment i have the following css

html{
overflow : hidden;
}

how can i change overflow to 'scroll' with javascript?

With jQuery:

$('html').css({overflow: 'scroll'});

Simple JavaScript

document.getElementsByTagName('html')[0].style.overflow = "scroll";

I hope this helps.

For one thing set the body not html

To change it to scroll do this:

document.body.style.overflow = "scroll";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM