![](/img/trans.png)
[英]How to load one html file from another html file while click on button in javascript?
[英]how to load an another html file on a button click in jquery mobile
我正在使用jQuery移动框架在phonegap中创建一个应用程序。
在我的index.html
文件中,我有两个文本框来接受用户名和密码。
当我单击“提交”按钮时,它将调用一个函数submitBtn()
,该函数检查用户名和密码是否正确,如果正确,则应加载我创建的“ selectOption.html”新的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>
我在<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>
正在调用该函数,但是如何加载selectOption.html
文件?
您是否尝试过使用jQuery Mobile方法执行导航?
$.mobile.changePage("newpage.html");
我找到了答案
加载任何您可以轻松完成的页面
$.mobile.changePage("yourHTML.html","slideup");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.