js hide scrollbar code example
Example 1: hide scrollbar css
.scrollbar-hidden::-webkit-scrollbar {
display: none;
}
.scrollbar-hidden {
-ms-overflow-style: none;
scrollbar-width: none;
}
Example 2: remove scrollbar css
.example::-webkit-scrollbar {
display: none;
}
.example {
-ms-overflow-style: none;
}
Example 3: javascript hide scrollbar
// You can hide the document scrollbar with this...
document.body.style.overflow = 'hidden';
//...and unhide it with this:
document.body.style.overflow = 'visible';
// Or switch between them:
booleanCondition
? document.body.style.overflow = 'hidden'
: document.body.style.overflow = 'visible';
Example 4: javascript hide scrollbar
function HideScrollbar() {
var style = document.createElement("style");
style.innerHTML = `body::-webkit-scrollbar {display: none;}`;
document.head.appendChild(style);
}