简体   繁体   English

在准备好文档的平板电脑设备上使用jQuery的单击功能不起作用

[英]Click function not working using jquery on tablet device inside document ready

I am not a JS developer, I am just a Web Designer dealing with simple JS interaction most of the time. 我不是JS开发人员,我只是大部分时间处理简单JS交互的Web设计器。

I am using jquery-1.11.3 and jquery.mobile v1.4.5 with just core features and slider capability. 我使用的jquery-1.11.3和jquery.mobile v1.4.5仅具有核心功能和滑块功能。 As tablet I have a kindle with the firefox (beta) browser and an ipod with safari browser. 作为平板电脑,我喜欢使用Firefox(测试版)浏览器,而喜欢使用Safari浏览器的iPod。

I am having a problem in understanding some JS behaviours of tablets and browsers regarding the click event function and document ready 我在理解平板电脑和浏览器的某些有关点击事件功能和文档准备就绪的JS行为时遇到问题

$(function(){
  $('.menu-ham').click(function(){
    alert("test")
  });
});

the click event doesn't work on tablets but it works perfectly on web browsers. click事件不适用于平板电脑,但可以完美地在网络浏览器上使用。

Instead if use this outside the document ready 相反,如果在准备好的文档之外使用它

$(document).on('click', '.menu-ham', function(){
    alert("test")
})

it works like a charm. 它就像一个魅力。 Only that I am not sure if this it would create problem with the browser because not inside document.ready 只是我不确定这是否会对浏览器造成问题,因为不在document.ready内部

I tried to use as well 我也尝试使用

$(function(){
  $('.menu-ham').on('click', function(){
    alert("test")
  });
});

inside or outside the document ready and nothing works. 内部或外部文档准备就绪,没有任何效果。

"menu-ham" it is a button with that class. “菜单火腿”是该类的按钮。 I read about a lot of topics, who said to use cursor:pointer, who said to use ".on('click'" instead of the normal click event, or vclick, or bind or touchstart but none really worked a part the solution that I offered, and now I am very confused about the whole thing on why is working and the other are not when I read a lot of comments that the other solution should work. 我读了很多主题,谁说使用cursor:pointer,谁说使用“ .on('click'”代替常规的click事件,或vclick,bind或touchstart,但没有一个真正起作用我提供了这些信息,现在我对整个原因感到困惑,为什么无法正常工作,而当我阅读了很多有关其他解决方案应该起作用的评论时,其他问题就没有了。

Any help would be very much appreciated, thank you! 任何帮助将不胜感激,谢谢!

I found the problem! 我发现了问题! it was all fault of Phalcon debugbar. 这都是Phalcon调试栏的错误。 On the mobile devices was generating an error that it wasn't happening on the normal browser. 在移动设备上生成的错误是普通浏览器上没有发生的。 This error was making any jquery or selectors working. 此错误导致任何jquery或选择器正常工作。

Thank you for your help and support! 感谢您的帮助和支持!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使使用document.ready(),jQuery单击功能也无法正常工作 - jQuery click function not working even after using document.ready() 即使使用$(document).ready(function(){}),jquery click函数也无法运行; 甚至在使用$(function)块之后 - jquery click function not working even after using $(document).ready(function() {}); and even after using $(function) block JavaScript .click函数在$(document).ready标签{}中不起作用 - JavaScript .click function not working inside $(document).ready tags{} JQuery $(document).ready(function()无效 - JQuery $(document).ready(function () not working Javascript - 函数在jQuery(document).ready中不起作用(Google map geocode) - Javascript - function not working inside jQuery(document).ready (Google map geocode) jQuery 文档中的调用函数准备就绪 - Calling function inside jQuery document ready document.ready函数在iframe中不起作用 - document.ready function is not working inside an iframe 我的文档.ready功能上的jQuery块无法正常工作 - Jquery Block on my document .ready function not working 如何在jQuery中声明此函数? $ {document).ready无法正常工作 - How to declare this function in jQuery? $(document).ready is not working Jquery 触发器 function 未准备好文档 - Jquery Trigger function not working with document ready
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM