I just strated with cordova project. In my HTML there is a button and i want to add click event for that. Click event function is written in external JS file. But unfortunately the function is not getting called. Given below is my HTML and JS files. please help me
index.html
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<meta name="msapplication-tap-highlight" content="no" />
<title>Hello World</title>
</head>
<body>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
<div>
<h1 id="login">Login</h1>
<div class="label_edit">
<div type="label"; id = "username_lbl" class="label">USERNAME
<input type="text"; id = "username_edit" class="edit" />
</div>
</div>
<div class="label_edit">
<div type="label"; id = "password_lbl" class="label">PASSWORD
<input type="password"; id = "password_edit" class="edit"/>
</div>
</div>
<br/>
<input type="button" value="submit" id="login_submit" onclick="submitBtnFunc();"/>
</div>
</body>
index.js
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
app.submitBtnFunc(id);
},
function submitBtnFunc(id)
{
alert("user name is :");
var username = document.getElementById("username_edit").value;
alert(username);
}
};