I\'m building my application through PhoneGap Build online. I want to change the default behavior of Back Button
$(document).ready(function(
Its said in Cordova API documentation that
Typically, you will want to attach an event listener with document.addEventListener once you receive the PhoneGap 'deviceready' event.
So change your code like this
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
function onDeviceReady() {
// Register the event listener
document.addEventListener("backbutton", onBackKeyDown, false);
}
// Handle the back button
function onBackKeyDown() {
//Your backbutton code
}