0

I tested on the Apple device, and when I click on the screen when there is no effect. This is my code. Click on the events of this writing there are questions?

    <script>
        $(function() {
            $('#test').tap(function() {
                $('#menuNum').text('1');
            })
        })
    </script>
cc29
  • 1

1 Answers1

0

You need to change few things.

Do not use $(function() { or classic document ready to check for a correct state, they can cause problems with jQuery Mobile. Instead use jQuery Mobile alternative called page events.

Then don't bind tap event like that, use proper modern way of doing that. In your case element must be loaded into the DOM for that kind of binding to work. And because of $(function() { sometimes it can happen that element is still loading when binding is executed. So use it like this:

$(document).on('tap','#test',function() {
    $('#menuNum').text('1');
});

This method don't care if element exist or not, it will even work if element is loaded into the DOM after binding process.

Working example: http://jsfiddle.net/Gajotres/SQ7DF/

In the end you want something like this:

$(document).on('pagebeforeshow', '#index', function(){ 
    $(document).on('tap','#test',function() {
        alert('Tap');
    });       
});
Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130
  • I say to you modified the code, but on the phone or not. You can leave a mail do I contact you, this problem has troubled me one afternoon. – cc29 May 24 '13 at 11:05