Having a table with input fields as td. Example of input field:
`<input type="text" value="20.300,00" style="max-width: 95px;">`
Im trying to disable the ability to scroll in this element. This is my code:
`$(document).on("wheel", function(event) {
if ($(document.activeElement).is("input[type='text']")) {
$(document.activeElement).blur();
}
});`
With this code, it’s still possible to scroll once, which changes the value once and afterwards its removing focus from the input field.
How can i completely remove the ability to scroll?
I’ve tried to use:
`event.preventDefault();`
That doesn’t seem to be a option.
3
Answers
Good afternoon,
You could take a look at this answer, There is no builtin feature to prevent this as far as I know.
Anyway the post I linked shows you how to ‘disable’ mousewheel scrolling while the input element is active.
Hope it helps!
Note: you would obviously change
input[type=number]
toinput[type=text]
I think if you will add event.preventDefault() inside your if condition then I think it will do the job.
You should be able to reset the scroll to zero, which effectively disables scrolling.
And if you wanted to re-enable scrolling on some event or interaction.