大佬教程收集整理的这篇文章主要介绍了jQuery mobile tap event触发两次,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE html> <html> <head> <title>Demo</title> <Meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.js"></script> <style> #Box{ BACkground-color:red; width:200px; height:200px; } </style> </head> <body> <div id="Box"> tapped me </div> <script type="text/javascript"> $(document).ready(function() { $('#Box').bind('tap',function(event) { alert('why'); }); }); </script> </body> </html>
更讽刺的是,当我通过jsfiddle测试这个,它只是发射了一次事件.
这是链接.
http://jsfiddle.net/mochatony/tzQ6D/6/
经过进一步的测试,我发现bug已经消失了放置在标题部分的JavaScript.
<!DOCTYPE html> <html> <head> <title>Demo</title> <Meta name="viewport" content="width=device-width,user-scalable=no"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script> <script type="text/javascript" src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.js"> </script> <style type="text/css"> #Box{ BACkground-color:red; width:200px; height:200px; } </style> <script type="text/javascript"> $(document).ready(function() { $('#Box').bind('tap',function(event) { alert('halo'); }); }); </script> </head> <body> <div id="Box"> tapped me </div> </body> </html>
我无法解释为什么身体和头部部分的位置使得这不同.
以上是大佬教程为你收集整理的jQuery mobile tap event触发两次全部内容,希望文章能够帮你解决jQuery mobile tap event触发两次所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。