Cordova按钮在android 9上不起作用,新手需要

问题描述 投票:0回答:1

我只是试图制作一个按钮(id =“ clickme”)链接index.html和js / buttonexample.js。我看到了按钮,但是它不起作用。我在浏览器和android模拟器上都尝试过。

js / buttonexample.js

document.getElementById("clickme").addEventListener("click", msg());
function msg() {
        alert("good"); 
}

index.html

<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/buttonexample.js"></script>
<div><Button id = "clickme">click</Button></div>

参照Cordova: onclick event is calling before button click我也试过

document.getElementById("clickme").addEventListener("click", msg);
javascript html cordova button
1个回答
0
投票
<Button id = "clickme">click</Button>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/buttonexample.js"></script>

将脚本上方的按钮放在mag之后,不带括号

document.getElementById("clickme").addEventListener("click", msg);
    function msg() {
            alert("good"); 
    }
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.