onclick事件不适用于ipad和平板电脑 [英] onclick event is not working on ipad and tablet

查看:316
本文介绍了onclick事件不适用于ipad和平板电脑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

onClick事件不适用于平板电脑,iPad?它完全在PC浏览器上工作,但不适用于触摸事件,我尝试过.binding(),on()和许多东西,但他们没有给出100%的结果。



<我怎样才能使它在ipad,平板电脑上工作?

 < div id =id1alt ='div1'class =sliderImagewidth =300height = 360onclick =style =visibility:hidden; background-image:url('img / img1.jpg'); border:solid; border-color:black;>您已将样式化为div设置宽度为100px。在一个合理的字体大小,这是太多的文字不适合100px。无需执行任何操作,< / div> 


解决方案

您需要使用touchstart我给你一个小例子,('click touchstart',function(){
console.log),

  $('elementid')。 ('1'); 
});

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


onClick event not working on tablet,ipad? it is perfectly working on Pc browser but not working for touch events , i tried .binding(),.on() and many thing but they are not giving 100% result.

How can I make it work on ipad , tablet??

<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>

解决方案

You need to use touchstart i get you a small example,

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

The touchstart event is fired when a touch point is placed on the touch surface.

这篇关于onclick事件不适用于ipad和平板电脑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆