0

Going a bit crazy with this one...

I have a simple event listener, which fires on desktop, but does not fire on mobile.

Before I investigate other scripts preventing my event listener from firing, I wonder if there were any limitations in run an eventlistener on an input dom element?

My code is simple!

<input name="login" class="button" id="signup-login" type="submit" value="Continue" ng-click="SignUp()">

document.getElementById("signup-login").addEventListener("click", function() {
   console.log('click!');
});

However, I cannot figure why something so simple, will not work in this scenario?

Any ideas, would be greatly appreciated!

Thanks,

Reena Verma
  • 1,617
  • 2
  • 20
  • 47
  • What you mean by not working in Mobile devices. Is it a actual mobile device? If yes, how you are running your js code in mobile, please ellaborate. – Vimal Patel Oct 30 '20 at 17:05
  • Where on the page is the script? Is it loaded before the `` element or after? – ibrahim mahrir Oct 30 '20 at 17:05
  • @ibrahim mahrir The script is running at the end of the body tag, I haven't copied the whole code as its long. – Reena Verma Oct 30 '20 at 17:07
  • Hi @Vimal Patel - I'm click on the button on an apple device/safari and my event is not firing. But I can see it firing, when I click the element on desktop. – Reena Verma Oct 30 '20 at 17:08
  • 1
    the click event behaves in a different way on mobile devices. https://stackoverflow.com/questions/22015908/onclick-not-working-on-mobile-touch/22015946#22015946 – messerbill Oct 30 '20 at 17:10
  • Thank you @Dr.Tenma and messerbill, this worked! I didn't realise this - seems so simple - thank you! – Reena Verma Oct 30 '20 at 17:12
  • Seems that onClick() best to use on mobile: https://stackoverflow.com/questions/37273142/would-onclick-event-work-on-touch-on-touch-screen-devices – Reena Verma Oct 30 '20 at 17:12

0 Answers0