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/