I want alert window to be shown on button click. I tried to run it in browser. Also I tried to do it without jQuery - the same problem. On my HTML I have just a button:
<html>
<head>
<title>Device Ready Example</title>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script src="js/index.js"></script>
<button id="btn">BUTTON</button>
</head>
<body>
</body>
</html>
This is my JavaScript file (no error messages in Chrome's console):
function App() {
var initialize = function () {
onload();
}
onLoad = function () {
document.addEventListener('deviceready', function () {
$("#btn").click(
function () {
alert("ALERT");
}
);
}, false);
}
onDeviceReady = function () {
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
document.addEventListener("btn", onMenuKeyDown, false);
}
onPause = function () {
}
onResume = function () {
}
onMenukeyDown = function () {
$("#btn").click(
function () {
alert("ALERT");
}
);
}
};
var app = new App;