jquery - onclick 事件不适用于 ipad 和平板电脑

标签 jquery html ipad tablet

onClick 事件在平板电脑、iPad 上不起作用?它在 Pc 浏览器上完美运行,但不适用于触摸事件,我尝试了 .binding(),.on() 和很多东西,但它们没有给出 100% 的结果。

如何让它在 ipad ,平板电脑上工作?

<div id="id1" alt='div1' class="sliderImage" width="300" height="360" onclick="" style="visibility:hidden;background-image:url('img/img1.jpg'); border:solid; border-color: black;">You've styled the div to have a set width of 100px. At a reasonable font size, that's too much text to fit in 100px. Without doing anything, </div>
<div id="id2" alt='div2' class="sliderImage" width="300" height="360" onclick="" style="visibility:hidden;background-image:url('img/img2.jpg'); border:solid; border-color: black;">this is 2</div>

最佳答案

你需要使用 touchstart 我给你举个小例子,

$('elementid').on('click touchstart', function() {
      console.log('1');
});

触摸点放在触摸表面上时会触发 touchstart 事件。

关于jquery - onclick 事件不适用于 ipad 和平板电脑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17161514/

相关文章:

javascript - jQuery $.post 适用于 chrome、safari,但不适用于 FF(声明成功回调函数未定义)

jquery - 如何解决响应中的高度问题?

html - 使用顶部三 Angular 形向 div 添加边框

javascript - Bootstrap 模态背景滚动问题

javascript - 使用插入值显示斐波那契数列

Jquery 数据表,标题和行 :select all checkbox not working 中带有复选框

html - 奇怪的 <li> 行为

ipad - 播放youtube视频-ipad

ios - Sprite 数组不响应触摸移动

ipad - 使用 WhirlyGlobeComponet 在地球上创建纬度线时出现问题