编辑下面的代码:【加编码】
<html> <head> <link rel="stylesheet" href="https://libs.baidu.com/jquerymobile/1.4.2/jquery.mobile.min.css"> <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script src="https://libs.baidu.com/jquerymobile/1.4.2/jquery.mobile.min.js"></script> <script> $(document).on("pagebeforeshow","#pagetwo",function(){ alert("触发 pagebeforeshow 事件 - 页面二即将显示"); }); $(document).on("pageshow","#pagetwo",function(){ alert("触发 pageshow 事件 - 现在显示页面二"); }); $(document).on("pagebeforehide","#pagetwo",function(){ alert("触发 pagebeforehide 事件 - 页面二即将隐藏"); }); $(document).on("pagehide","#pagetwo",function(){ alert("触发 pagehide 事件 - 现在隐藏页面二"); }); </script> </head> <body> <div data-role="page" id="pageone"> <div data-role="header"> <h1>页眉文本</h1> </div> <div data-role="content"> <p>页面一</p> <a href="/demo/tryjqmob_events_page_transitions.htm#pagetwo">转到页面二</a> </div> <div data-role="footer"> <h1>页脚文本</h1> </div> </div> <div data-role="page" id="pagetwo"> <div data-role="header"> <h1>页眉文本</h1> </div> <div data-role="content"> <p>页面二</p> <a href="/demo/tryjqmob_events_page_transitions.htm#pageone">转到页面一</a> </div> <div data-role="footer"> <h1>页脚文本</h1> </div> </div> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂