Jason
Jason

Reputation: 81

Javascript On Click Or Touch

I'm trying to submit a form that is hidden when the user clicks a button. The form doesn't need any user info, they just have to click the submit button to be taken to another page.

I have the button coded below

<li class="get-started menu-item-6703">
    <a href="#!">Donate</a>
</li>

Here is the script that simulates a click on the hidden submit button. For whatever reason, this isn't working in mobile (iOS and probably Android too).

<script type="text/javascript">
$(document).ready(function() {
    $('.get-started').on('click',function() {
        document.getElementById("scf-donate").submit();
        return false;
    });
});
</script>

Upvotes: 2

Views: 298

Answers (1)

DreamTeK
DreamTeK

Reputation: 34287

Click events currently do not work with IOS browsers as they implement touch behaviour instead.

Try:

$(function() {
  $('.get-started').on('touchend mouseup',function() {
    document.getElementById("scf-donate").submit();
      return false;
  });
});

Behaviour

If a Web application can process touch events, it can intercept them, and no corresponding mouse events would need to be dispatched by the user agent. If the Web application is not specifically written for touch input devices, it can react to the subsequent mouse events instead.

Efforts are being made to reconcile both click and touch event behaviour but IOS currently still relies on touch events.

Upvotes: 1

Related Questions