stut.io

Input type number disable scroll

Scroll on input[type=number] changes input value which can be annoying. To disable scrolling, use one of these solutions:

Solution 1 for jQuery:

$('input[type=number]').on('mousewheel',function(e) {
  $(this).blur();
});

Solution 2 for jQuery:

$(document).on("wheel", "input[type=number]", function (e) {
  $(this).blur();
});

Solution for plain JavaScript or VanillaJS:

document.addEventListener("wheel", function(event) {
  if (document.activeElement.type === "number") {
    document.activeElement.blur();
  }
});