Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

javascript

css

at the moment i have the following css

html{
overflow : hidden;
}

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

like image 446
code511788465541441 Avatar asked Sep 12 '25 09:09

code511788465541441


2 Answers

With jQuery:

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

Simple JavaScript

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

I hope this helps.

like image 107
Senad Meškin Avatar answered Sep 14 '25 00:09

Senad Meškin


For one thing set the body not html

To change it to scroll do this:

document.body.style.overflow = "scroll";
like image 43
Naftali Avatar answered Sep 14 '25 00:09

Naftali