I try to create button which starts an alert after a click event. Something like that :
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
<button onclick="alert('salut')" id="boutonAlerte">Alerte</button>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script> </body>
but the problem is that my onclick doesn't work. A lot of people tell me to try it on javascript so I've decided to write something like that :
function onAlertClick() {
alert("ceci est une alerte");
}
alert("test2");
var bA = document.getElementById("boutonAlerte");
bA.addEventListener("onclick", onAlertClick());
But this is the same thing.
Any ideas ?
Try adding jQuery click event, which are working fine with my cordova apps
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.3.js"></script>
<script type="text/javascript">
$("#boutonAlerte").click(function(){
alert("ceci est une alerte");
});
</script>
Here is JSFiddle link