在PhoneGap 2.9中使用jQuery/JavaScript单击按钮事件不起任何作用
我正在使用PhoneGap2.9和EclipseJuno为android开发一个移动应用程序。我看到了很多关于使用Javascript和JQuery的按钮点击事件的帖子,但似乎没有任何效果。我的意思是,当我点击按钮时,不会出现警报!我也尝试了这两个在PhoneGap 2.9中使用jQuery/JavaScript单击按钮事件不起任何作用,javascript,android,cordova,buttonclick,Javascript,Android,Cordova,Buttonclick,我正在使用PhoneGap2.9和EclipseJuno为android开发一个移动应用程序。我看到了很多关于使用Javascript和JQuery的按钮点击事件的帖子,但似乎没有任何效果。我的意思是,当我点击按钮时,不会出现警报!我也尝试了这两个我终于解决了我的问题
我终于解决了我的问题<这与按钮无关。问题在于Java脚本
<title>Guide-Me For-All</title>
<link href='http://fonts.googleapis.com/css?family=Patrick+Hand|Permanent+Marker|Exo|Nunito|Limelight|Ubuntu|Montserrat|Audiowide|Architects+Daughter' rel='stylesheet' type='text/css'>
<!-- import stylesheets -->
<link rel="stylesheet" type="text/css" href="../css/home.css">
<link rel="stylesheet" type="text/css" href="../css/home-eng-fonts.css">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css" />
<link rel="stylesheet" href="../jQuery-Mobile-Bootstrap-Theme-master/themes/Bootstrap.css">
<!-- import js -->
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../jss/connect.js"></script>
<script type="text/javascript" charset="utf-8" src="../jss/change_page.js"></script>
<script src="../plugins/page-swipe-iscroll/iscroll.js"></script>
<script src="../plugins/page-swipe-iscroll/scroll.js"></script>
- 首先,我更改了调用
home.html
和sign-up.html
的JavaScripts的顺序(1.来自web的JQuerys,2.cordova.js,3.connect.js,4.所有其他JavaScripts)
home.html
:
<title>Guide-Me For-All</title>
<link href='http://fonts.googleapis.com/css?family=Patrick+Hand|Permanent+Marker|Exo|Nunito|Limelight|Ubuntu|Montserrat|Audiowide|Architects+Daughter' rel='stylesheet' type='text/css'>
<!-- import stylesheets -->
<link rel="stylesheet" type="text/css" href="../css/home.css">
<link rel="stylesheet" type="text/css" href="../css/home-eng-fonts.css">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css" />
<link rel="stylesheet" href="../jQuery-Mobile-Bootstrap-Theme-master/themes/Bootstrap.css">
<!-- import js -->
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../jss/connect.js"></script>
<script type="text/javascript" charset="utf-8" src="../jss/change_page.js"></script>
<script src="../plugins/page-swipe-iscroll/iscroll.js"></script>
<script src="../plugins/page-swipe-iscroll/scroll.js"></script>
<title>Guide-Me For-All</title>
<link href='http://fonts.googleapis.com/css?family=Patrick+Hand|Permanent+Marker|Exo|Nunito|Limelight|Ubuntu|Montserrat|Audiowide|Architects+Daughter' rel='stylesheet' type='text/css'>
<!-- import stylesheets -->
<link rel="stylesheet" type="text/css" href="../css/home.css">
<link rel="stylesheet" type="text/css" href="../css/home-eng-fonts.css">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css" />
<link rel="stylesheet" href="../jQuery-Mobile-Bootstrap-Theme-master/themes/Bootstrap.css">
<!-- import js -->
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../jss/connect.js"></script>
<script type="text/javascript" charset="utf-8" src="../jss/change_page.js"></script>
<script src="../plugins/page-swipe-iscroll/iscroll.js"></script>
<script src="../plugins/page-swipe-iscroll/scroll.js"></script>
这是必需的,因为当我在谷歌上阅读时,最好是从JavaScript更改页面,而不是,我以为我会在编辑你的代码时死去。。。关于问题:看一下。我对编辑感到抱歉。只是我没有时间自己修好,网络连接很糟糕。我现在会检查它,即使我看到它不是关于点击事件按钮。我将看到JavaScript中的逻辑。谢谢你哦,我也编辑了你的格式化代码。这是一种痛苦:(.请检查代码的格式是否正确。你需要使用一个好的编辑器。.WebStorm、sublime text、Notepad++等都是HTML和JS的好编辑器。我使用sublime text。在完全编辑格式之前,我不会发布任何东西。谢谢你,我很抱歉。@marialena那么问题是什么-提到的链接有帮助吗?
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.getElementById('submitt').addEventListener('click', checkk, false);
function checkk(){
navigator.notification.alert("I am here.", null, 'Here', 'Okay');
}
}
<title>Guide-Me For-All</title>
<link href='http://fonts.googleapis.com/css?family=Patrick+Hand|Permanent+Marker|Exo|Nunito|Limelight|Ubuntu|Montserrat|Audiowide|Architects+Daughter' rel='stylesheet' type='text/css'>
<!-- import stylesheets -->
<link rel="stylesheet" type="text/css" href="../css/home.css">
<link rel="stylesheet" type="text/css" href="../css/home-eng-fonts.css">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css" />
<link rel="stylesheet" href="../jQuery-Mobile-Bootstrap-Theme-master/themes/Bootstrap.css">
<!-- import js -->
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../jss/connect.js"></script>
<script type="text/javascript" charset="utf-8" src="../jss/change_page.js"></script>
<script src="../plugins/page-swipe-iscroll/iscroll.js"></script>
<script src="../plugins/page-swipe-iscroll/scroll.js"></script>
<a href="#" data-role="button" data-theme="f" data-icon="heart" onclick="change_page();">Sign-Up Now!</a>
// PhoneGap is ready
//
function onDeviceReady() {
// Empty
}
// alert dialog dismissed
function alertDismissed() {
// do something
}
// Show a custom alert
//
function change_page() {
document.location.href = '../htmls/sign-up.html';
}
<a href="#" onclick="register();" data-role="button" data-theme="a">Register</a>
// PhoneGap is ready
//
function onDeviceReady() {
// Empty
}
// alert dialog dismissed
function alertDismissed() {
// do something
}
// Show a custom alert
//
function register() {
navigator.notification.alert(
'hello!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
}