$.fn.horizontalScroll = function (amount = null) { amount = amount || 40; $(this).on('DOMMouseScroll mousewheel', function (event, delta) { this.scrollLeft -= (delta * amount); event.preventDefault(); }); };