Onchange Event Not Triggered on Drag in Firefox for Input Type Range
The onchange event for an element typically fires when the user changes its value. However, in Firefox, this event is only triggered when the slider is released after being dragged. This differs from browsers like Chrome, where the event is fired during the drag operation.
Solution: Using oninput Event
To resolve this discrepancy and enable continuous value updates during drag in Firefox, it is recommended to use the oninput event instead of onchange. The oninput event captures live updates from both mouse and keyboard input, ensuring continuous value updates in all major browsers, including Firefox, Safari, and Chrome.
Combining oninput and onchange
For support in older browsers like IE10, which do not support oninput, you can combine both event handlers. This ensures that both continuous value updates during drag and the final value update on release are handled:
Additional Information
For further details on the behavior of the onchange event in browsers, refer to the following Bugzilla thread: https://bugzilla.mozilla.org/show_bug.cgi?id=1145662.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3