jquery mobile跳转到指定id时怎样传递参数

在jquery mobile 中,每一个页面都是一个page,当我们需要从一个页面跳转到另一个页面时,可以在href中指定id,可是该怎么把一个page中的参数传递到另外一个page中,几经琢磨,发现可以通过点击函数的参数来传递值,代码如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js" type="text/javascript"></script>
</head>

<body>
<script>
function goto_other_page(username){
    $("#page2_username").text(username);
    };
</script>
<div data-role="page" id="page1">
  <div data-role="header">
    <h1>标题</h1>
  </div>
  <div data-role="content">
    <ul data-role="listview">
    <!--函数中的参数可以根据需要,通过拼接的方式动态添加-->
      <li><a href="#page2" onClick="goto_other_page('张三');">页面</a></li>
    </ul>



  </div>
  <div data-role="footer" data-position="fixed">
    <h4>脚注</h4>
  </div>
</div>
<div data-role="page" id="page2">
  <div data-role="header">
    <h1>标题</h1>
  </div>
  <div data-role="content">
    <label id="page2_username"></label>
  </div>
  <div data-role="footer" data-position="fixed">
    <h4>脚注</h4>
  </div>
</div>

</body>
</html>

转载于:https://www.cnblogs.com/lenve/p/4445109.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值