Reputation: 583
I have my web app working fine with computers, but can't seem to get it to work on mobile phones mainly because the onmouseup isn't being fired off. So I added the touchend event thinking it would be the same, but it didn't help. How do I get the same behavior of onmouseup on the phone?
Basically, I have a range slider and I want the release slider part of it to work on phones
<input id="slider" class="slider" type="range" min="0" max="100" value=50 onmouseup="handleSubmit()" touchend="handleSubmit()"/>
I've tried it on mobile safari and chrome... neither work
Upvotes: 0
Views: 357
Reputation: 12891
You don't need to rely on mouseup nor touchend. The input element offers another event which comes in handy: onchange.
This input fires as soon the input's value changed - because the user released the slider.
Here's an example:
function handleSubmit(e) {
console.log(e.value)
}
<input id="slider" class="slider" type="range" min="0" max="100" value=50 onchange="handleSubmit(this)" />
Upvotes: 1
Reputation: 583
I'm stupid... it's supposed to be ontouchend
<input id="slider" class="slider" type="range" min="0" max="100" value=50 onmouseup="handleSubmit()" touchend="handleSubmit()"/>
still new to js haha
Upvotes: 0