---写id--此方法只能在真机上运行调试
<!doctype html> <html> <head> <meta charset="UTF-8"> <title></title> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <link href="css/mui.min.css" rel="stylesheet" /> </head> <body> <div class="mui-content"> <button type="button" id="btn1">测试</button> </div> <script src="js/mui.min.js"></script> <script type="text/javascript"> mui.init(); /*真机环境下运行调试*/ mui.plusReady(function(){ document.getElementById('btn1').addEventListener('tap',function(){/*tap表示单击屏幕,此处可换双击,滑动等等事件*/ mui.toast('ok'); }); }); </script> </body> </html>
document.getElementById('btn1').addEventListener('tap',function(){/*tap表示单击屏幕,此处可换双击,滑动等等事件*/
如下属性
----第二种方法 on()方法
<!doctype html> <html> <head> <meta charset="UTF-8"> <title></title> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <link href="css/mui.min.css" rel="stylesheet" /> </head> <body> <div class="mui-content"> <ul class="mui-table-view" id="lists"> <li class="mui-table-view-cell">列表一</li> <li class="mui-table-view-cell">列表一</li> <li class="mui-table-view-cell">列表一</li> </ul> </div> <script src="js/mui.min.js"></script> <script type="text/javascript"> mui.init(); /*真机环境下运行调试*/ mui.plusReady(function(){ mui('#lists').on('tap','li',function(){ /* mui.toast('ok');*/ mui.toast(this.innerHTML);/*显示点击的内容*/ }); }); </script> </body> </html>