<style type="text/css"> /*盒子大小從邊框開始計算*/ html * { box-sizing: border-box; } /*解決模態框抖動*/ html { overflow-y: scroll; -ms-overflow-style: none; } /* 隱藏滾動條 */ html::-webkit-scrollbar { display: none; } body { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; } /* 去除webkit中input的type="number"時出現的上下圖標 */ input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; } input[type="number"] { -moz-appearance: textfield; } </style>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>禁止input輸入框的鼠標滾輪事件</title> <script src="jquery.js"></script> </head> <body> <!-- 禁止谷歌瀏覽器、Opera瀏覽器以及360瀏覽器等採用谷歌內核的瀏覽器 --> <input type="number" id="inp1" onmousewheel="return false;"> <!-- 禁止Firefox瀏覽器 --> <input type="number" id="inp2"> <script> $("#inp2")[0].addEventListener('DOMMouseScroll', MouseWheel, false); function MouseWheel(event) { event = event || window.event; event.preventDefault(); } </script> </body> </html>
出自:https://www.cnblogs.com/lhl66/p/9164000.htmlcss