Skip to content

Instantly share code, notes, and snippets.

@JaisonBrooks
Last active July 11, 2022 15:09
Show Gist options
  • Save JaisonBrooks/a36eaffde87a41921d13 to your computer and use it in GitHub Desktop.
Save JaisonBrooks/a36eaffde87a41921d13 to your computer and use it in GitHub Desktop.
Disable Input[type=number] scroll action
// Disable Mouse scrolling
$('input[type=number]').on('mousewheel',function(e){ $(this).blur(); });
// Disable keyboard scrolling
$('input[type=number]').on('keydown',function(e) {
var key = e.charCode || e.keyCode;
// Disable Up and Down Arrows on Keyboard
if(key == 38 || key == 40 ) {
e.preventDefault();
} else {
return;
}
});
// THEN DISABLE ARROWS IN CSS
// input[type=number]::-webkit-inner-spin-button,
// input[type=number]::-webkit-outer-spin-button {
// -webkit-appearance: none;
// margin: 0;
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment