Prevent body from scrolling when opening a modal

// Disable scrolling on the `body` element when opening a modal
document.body.style.overflow = 'hidden';

// Allow to scroll when closing the modal
document.body.style.removeProperty('overflow');

More

Previous
Prepend to an element
Next
Preview an image before uploading it