cordova/phonegap onclick doesn't work

前端 未结 7 1754
小鲜肉
小鲜肉 2021-01-21 14:34

I try to create button which starts an alert after a click event. Something like that :

    
    

Apache

7条回答
  •  终归单人心
    2021-01-21 15:22

    onclick is not fired on cordova apps, because users don't "click", instead, they "tap". You may use a decent mobile framework like Ionic, and use ng-click, it automatically solves the problem for you, because it includes ngTouch.

    If you prefer not to use a big framework like angular, you may use Zepto.js, and use $(".element").on('tap', callback); to listen for tap events. Or $(".element").on('tap click', callback); to listen for both tap and click events.

    Chrome dev tools has good mobile emulation, to trigger tap events. It may be helpful if you want to debug you app in Chrome.

提交回复
热议问题