Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
189
rated 0 times [  195] [ 6]  / answers: 1 / hits: 20975  / 8 Years ago, sun, april 24, 2016, 12:00:00

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 ?


More From » android

 Answers
14

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



https://jsfiddle.net/9v85ku5y/


[#62418] Thursday, April 21, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kennedi

Total Points: 702
Total Questions: 109
Total Answers: 111

Location: Vietnam
Member since Sun, Oct 18, 2020
4 Years ago
;