Forked from JaisonBrooks/remove_input_number_scroll.js
Created
August 2, 2018 11:03
-
-
Save cycold/7f5471968fc373a8c2af4f3cd8b81a39 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