$(document).ready(function() { var $content = $('.forScroll'); var isDown = false; var startX, startY, scrollLeft, scrollTop; $content.on('mousedown', function(e) { isDown = true; $content.css('cursor', 'grabbing'); startX = e.pageX - $content.offset().left; startY = e.pageY - $content.offset().top; scrollLeft = $content.scrollLeft(); scrollTop = $content.scroll..