这是我的 html 第一个页面,我们将在其中填写详细信息
<div data-role="content">
<div data-role="fieldcontain">
<label for="name1">Name</label>
<input name="name1" id="name1" value="" type="text">
</div>
<div data-role="fieldcontain">
<label for="age">Age</label>
<input name="age" id="age" value="" type="text">
</div>
<div data-role="fieldcontain">
<label for="address">Address</label>
<input name="address" id="address" value="" type="text">
</div>
<div data-role="fieldcontain">
<label for="mobile">Mobile</label>
<input name="mobilet" id="mobile" value="" type="text">
</div>
<div data-role="button" data-theme="b" data-inline="true" id="button">Submit</div>
</div>
下面是第二页,我们将在其中显示填充的数据,将给出一个编辑按钮,将用户再次带到第一页。
<div data-role="content" id="content2">
<form id="form1">
<div data-role="fieldcontain">
<label for="name">Name</label>
<span class="field" style="padding:350px;" id="un"></span>
</div>
<div data-role="fieldcontain">
<label for="age">age</label>
<span class="field1" style="padding:350px;" id="pw"></span>
</div>
<div data-role="fieldcontain">
<label for="address">Address</label>
<span class="field2" style="padding:350px;" id="au"></span>
</div>
<div data-role="fieldcontain">
<label for="mobile">Mobile</label>
<span class="field3" style="padding:350px;" id="fr"></span>
</div>
<div style="text-align:center;">
<div data-role="button" data-theme="b" data-inline="true" id="button2">Edit</div>
</div>
</form>
</div>
在jQuery中: -
$(document).unbind('pageinit').bind('pageinit', function () {
$("#button1").click(function () {
callConnection();
});
$("#button2").click(function () {
callEditConnection();
});
});
function callConnection(){
localStorage.setItem("user", $("#name1").val());
localStorage.setItem("pass", $("#age").val());
$.mobile.changePage("#page2");
}
function callEditConnection(){
$("#un").val(localStorage.getItem("user"));
$("#pw").val(localStorage.getItem("pass"));
$.mobile.changePage("#page1");
}
请帮助我找出我的代码存在什么问题,即 page2 的值没有出现