Aje*_*rya 1 javascript jquery jquery-mobile cordova
我正在使用jQuery移动框架在phonegap中创建一个应用程序.
在我的index.html文件中,我有两个文本框来接受用户名和密码.
当我点击提交按钮时,它调用一个函数submitBtn()来检查用户名和密码是否正确,如果它是正确的,那么它应该加载一个我创建的新的html文件`selectOption.html'
这是我的代码
<script type="text/javascript">
$(document).ready(function() {
var userName;
var userPassword;
$("#submitBtn").click(function() {
//alert("HI");
userName = $("#UserName").val();
userPassword = $("#Password").val();
if ((!UserName)|| (!userPassword)) {
alert("Enter the Details");
}
else {
if ((userName !="alpha") ||(userPassword !="beta")) {
alert('Enter correct username and password');
}
else {
//here i want to load my selectOption.html file ?
}
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
我的代码<body>是
<body>
<div data-role="page" id="home">
<div data-role="header">
<h1>Enter Credential</h1>
</div>
<div data-role="content">
<label for="UserName">User Name</label>
<input type="text" name="UserName" id="UserName" value="" style="width:220px;" />
<label for="Password">Password</label>
<input type="password" name="Password" id="Password" value="" style="width:220px;" />
<div id="submitBtn" data-role="button">Submit</div>
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
函数被调用,但如何加载selectOption.html文件?
您是否尝试过使用jQuery Mobile方法执行导航?
$.mobile.changePage("newpage.html");
Run Code Online (Sandbox Code Playgroud)
http://jquerymobile.com/demos/1.0/docs/api/methods.html