cordova/phonegap onclick doesn't work

前端 未结 7 1744
小鲜肉
小鲜肉 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:31

    Here is a jQuery example

    html

                EXECUTE    
    

    jquery

    $(".start-button").click(function (e) {  //note that 'onclick="HandleExec();return false;" doesnt work
        e.preventDefault();
        // here you can handle the click code you wanted
    });
    

    make sure that you call event.preventDefault(); so it doesn't try to go to the href in the html tag. That will just reload the cordova app in this case.

提交回复
热议问题