Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Would onClick event work on touch on touch-screen devices?

I've used onclick events in my website. But when I open it in google chromes' developer mode's mobile view, nothing happens on touch on the elements which work on click with mouse. So my question is:

Do I have to also add ontouch events along with onclick events, or onClick event work on touch on all touch-screen devices?

P.S: You can see all of my codes here: https://github.com/SycoScientistRecords/sycoscientistrecords.github.io/

Or at the live website: http://sycoscientistrecords.github.io

And no I haven't tested the website on real phone.

like image 397
user31782 Avatar asked May 17 '16 10:05

user31782


People also ask

Does Click work for mobile devices?

Yes it will work.

Can I use touch events?

Touch events are supported by Chrome and Firefox on desktop, and by Safari on iOS and Chrome and the Android browser on Android, as well as other mobile browsers like the Blackberry browser.

Is Onclick a mouse event?

The onmousedown , onmouseup , and onclick events are all parts of a mouse-click. First when a mouse-button is clicked, the onmousedown event is triggered, then, when the mouse-button is released, the onmouseup event is triggered, finally, when the mouse-click is completed, the onclick event is triggered.


1 Answers

onclick works fine on touchscreens; I've used it several times and have never had any problem.

You could consider using onmousedown instead of onclick. Or use jQuery to detect taps.

like image 53
Mueyiwa Moses Ikomi Avatar answered Sep 19 '22 07:09

Mueyiwa Moses Ikomi