标签:oct 无效 utf-8 rip html dex test java ble
jQuery,zepto手机端用on将子元素事件委托给body或document无效
在移动端,绑定在普通的div元素上是可以的,但是绑定在body上无效,document也是无效。
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <title>test-on</title> <style> .a{width: 100px;height: 40px;background: #7892a6;margin: 50px;} </style> </head> <body> <div class="k"> <div class="a b">k</div> <div class="a b">k</div> <div class="a b">k</div> </div> <div> <div class="a d">body</div> <div class="a d">body</div> <div class="a d">body</div> </div> <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script> <script> $("body").on("click",".d",function(){ alert($(this).index(".a")); }); $(".k").on("click",".b",function(){ alert($(this).index(".a")); }); </script> </body> </html>
jQuery,zepto手机端用on将子元素事件委托给body或document无效
标签:oct 无效 utf-8 rip html dex test java ble
原文地址:http://www.cnblogs.com/mrGan/p/7491443.html