Forked from JaisonBrooks/remove_input_number_scroll.js
Created
March 4, 2020 10:27
-
-
Save ss81/672ead66089947ca689912b682fa7bf8 to your computer and use it in GitHub Desktop.
Disable Input[type=number] scroll action
This file contains hidden or 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