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() {
$("#myEl").trigger('click');
$("#myEl").trigger('touchstart');
}
window.onload = myFunction;
For touch event, visit below link.
https://developer.mozilla.org/en-US/docs/Web/Events/touchstart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With