I'm trying to toggle the scrollbar of the <html> tag using jquery.
I want the scrollbar to disappear when i click on button #foo, and i want it to reappear when i click on #bar1.
$('#foo').click(function() {
$('html').toggleClass("hidescroll");
});
$('#bar1').click(function() {
$('html').toggleClass("hidescroll");
});
.hidescroll{
overflow-y: hidden !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="foo">foo</div>
<div id="bar1">bar1</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
it disappears when i click on #foo, but it doesnt reappear on #bar1, however it reappears when #foo is clicked again.
.hidescrollfooandbar1in your html?