Possible duplicate? Copied directly from here: Disabling vertical scroll by mouse
$('#ab')
.bind('mousewheel DOMMouseScroll', function(e) {
e.preventDefault();
});
Or another one here: How to do a horizontal scroll on mouse wheel scroll?
var mouseWheelEvt = function (event) {
if (document.body.doScroll)
document.body.doScroll(event.wheelDelta>0?"left":"right");
else if ((event.wheelDelta || event.detail) > 0)
document.body.scrollLeft -= 10;
else
document.body.scrollLeft += 10;
return false;
}
document.body.addEventListener("mousewheel", mouseWheelEvt);
Update: I think this is the exact code you're looking for:
$('#ab').bind('mousewheel DOMMouseScroll', function(e) {
// Replace with != 0 if you want to prevent left/right instead.
if (e.originalEvent.wheelDeltaX == 0) {
e.preventDefault();
}
});
Example: http://jsfiddle.net/32w276xL/