Prevent scrolling of parent element – Jquery

Please ensure that you are include jquery.mousewheel.js

<!DOCTYPE html> 
<script class="jsbin" src=""></script>
<meta charset=utf-8 />
<title>JS Bin</title>

 * { padding: 0; margin: 0; }
 html { min-height: 1000%; }

 #toolbox {
 overflow: auto;
 position: fixed;
 top: 100px;
 left: 200px;
 width: 200px;
 height: 300px;
 background: #ccc;


 <div id="toolbox">
 <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>

 <script src=""></script>


$(function() {

 var toolbox = $('#toolbox'),
 height = toolbox.height(),
 scrollHeight = toolbox.get(0).scrollHeight;

 toolbox.bind('mousewheel', function(e, d) {
 if((this.scrollTop === (scrollHeight - height) && d < 0) || (this.scrollTop === 0 && d > 0)) {



Another example

$('div').on( 'mousewheel DOMMouseScroll', function (e) {

var e0 = e.originalEvent;
var delta = e0.wheelDelta || -e0.detail;

this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;


Recent Article

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  1. Hey all! Recently I have been fighting with a lot of personal issues. Friends and doctors keep telling me I should consider taking meds, so I may as well read more and see how it goes. Problem is, I haven’t taken it for a while, and don’t wanna get back to it, we’ll see how it goes.

  2. Just want to say your article is as amazing. The clearness in your post is just nice and i could assume you are an expert on this subject. Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please keep up the enjoyable work.