thatOneGuy thatOneGuy - 5 months ago 50
Javascript Question

Simulate click event on mobile device

I have a click event on window load like so :

function myFunction(){
document.getElementById('myEl').click(); // works on desktop, not on mobile

window.onload = myFunction;

As mentioned, this works on desktop but not on mobile devices. I gathered it was down to mobile handling click events differently. Is that correct ?

I need my element to be 'clicked' on load on all devices, desktop and touch pads (mobiles etc).

function myFunction() {
window.onload = myFunction;

For touch event, visit below link.