/    Sign up×
Community /Pin to ProfileBookmark

no-scroll class does not disable scrolling.

I am basically adding a no-scroll class to the body. Although nothing is changed and I can still scroll. I can see though that the class has actually been added to the body element. I have done the very same thing in my other project and worked great. No, I have copied that code into my new project and for some reason now it does not work. Still works on the old project though…
There isn’t much code to show but only this:

`
$(document).ready(function () {
$(‘.burger-menu’).click(function () {
$(this).toggleClass(‘menu-on’);
$(‘.mobile-menu’).toggleClass(‘open’);
if ($(‘.burger-menu’).hasClass(‘menu-on’)) {
$(‘body’).addClass(‘no-scroll’);
}
else {
$(‘body’).removeClass(‘no-scroll’);
}
});
});
`

And also mobile class and burger-menu don’t have the same parent. Only have a similar great-grand-dad which is header tag. There is not much code that that.

Would be so pleased if someone can give me an idea of whats going on 🙁

Thank you

to post a comment
CSSHTMLJavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@codewitchJul 19.2021 — Hello. Here is how to disable scroll in a html document:

<i>
</i>&lt;style&gt;
html, body {margin: 0; height: 100%; overflow: hidden}
&lt;/style&gt;
×

Success!

Help @weareandrei spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...