源代码:
下载代码
AI 编程工具
点击运行
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="https://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="https://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> <script> $(document).on("pagecreate","#pageone",function(){ $("p,button,h1").on("swipe",function(event){ $("span.test").html("在" + event.target.nodeName + " 元素上滑动。"); $("span.test2").html("事件触发: " + event.type); }); }); </script> </head> <body> <div data-role="page" id="pageone"> <div data-role="header"> <h1> swipe 事件</h1> </div> <div data-role="main" class="ui-content"> <h1>这是一个标题</h1> <p>这是一个段落</p> <button>这是一个按钮</button> <p>标题,段落,按钮已设置了滑动事件。点击每个元素查看触发的事件。</p> <span class="test" style="color:blue;"></span> <br><br> <span class="test2" style="color:red;"></span> </div> <div data-role="footer"> <h1>底部文本</h1> </div> </div> </body> </html>
运行结果: