Search code examples
htmlattributesevent-handling

Is there an HTML attribute/event handler for 'on mouse release'?


I need a function to be called when the slider knob has been released. onchange changes the value while I'm changing it. Is there a solution for this like

<input type="range" min="0" max="1000" onrelease="callfunction()">

Solution

  • Use the mouseup event on desktop browsers and the touchend event on mobile phones for handling this user interaction.

    <input type="range" min="0" max="1" 
           onmouseup="callfunction()" 
           ontouchend="callfunction()">
    

    I would recommend to check caniuse.com for browser support.

    Known issues (as of 2019-03-25):