S
S
soofftt912016-12-04 20:41:13
JavaScript
soofftt91, 2016-12-04 20:41:13

Why are JS functions not being called on iPhone 4?

Today, for the first time, I encountered such a problem: on the iPhone 4 (9.3.5) and iPad 2 (8.2), the functions I created are not called. At the same time, everything works clearly in the iPhone 5S (10.0.1).
Works:

<button type="button" onclick="alert('test')">test</button>

<script>
    $('#test').on('click', function(){alert('test')};
</script>
<button type="button" id="test">test</button>

Does not work:
<script>function test() {alert('test');}</script>
<button type="button" onclick="test()">test</button>

<script>var test = function () {alert('test');}</script>
<button type="button" onclick="test()">test</button>

<script>
    $('#test').on('click', function(){
        test();
    };
    function test() {alert('test');}
</script>
<button type="button" id="test">test</button>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2016-12-04
@Sanasol

click is for mice.
tap event on phones, maybe that's why it doesn't work

A
Adamos, 2017-04-03
@Adamos

function(e) {
      event.preventDefault();

Doesn't make you think?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question