cordova/phonegap onclick doesn't work

前端 未结 7 1739
小鲜肉
小鲜肉 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

                <a href="#" class="start-button">EXECUTE</a>    
    

    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.

    0 讨论(0)
提交回复
热议问题