• 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>
    
  • 相关阅读:
    MongoDB初期学习
    springboot+camunda实现工作流1
    一文带你深入理解位运算
    【林超所长】学科01:熵与热力学重要模型
    PM常用的讨论社区及牛人帖子
    C# 2.0 的特性 总结
    小脚本解决生活问题
    Domain Adaption 之 TCA等算法
    强化学习ddpg算法
    bindkey用法
  • 原文地址:https://www.cnblogs.com/lenve/p/4445109.html
Copyright © 2020-2023  润新知