Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- document.addEventListener("DOMContentLoaded", function () {
- const SELECTORS = ["[name=sHours]"];
- let fields = [];
- SELECTORS.forEach(function (s) {
- fields = fields.concat(Array.from(document.querySelectorAll(s)));
- });
- fields.forEach(function (field) {
- field.onwheel = function (event) {
- let value = parseInt(this.value, 10);
- const delta = parseInt(this.getAttribute("value"), 10) / 2;
- if (event.deltaY > 0) value -= delta;
- else if (event.deltaY < 0) value += delta;
- if (this.hasAttribute("min")) value = Math.max(value, parseInt(this.getAttribute("min"), 10));
- if (this.hasAttribute("max")) value = Math.min(value, parseInt(this.getAttribute("max"), 10));
- this.value = value;
- event.preventDefault();
- };
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement