Last active
July 11, 2022 15:09
-
-
Save JaisonBrooks/a36eaffde87a41921d13 to your computer and use it in GitHub Desktop.
Disable Input[type=number] scroll action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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