Clickable website image not working on iphone and android devices

老子叫甜甜 提交于 2019-12-02 00:58:04

Mobile Safari passes touch events through for things that are obviously touchable like links or buttons. However, if you are using Javascript to add touch events to other html elements like an <img> or <div> tag you can let Safari know it's touchable by setting style:

cursor:pointer;

either on the element or in a css class on the element.

If you can add a css class to one of your files, you could do something like this in the head section:

<script>
    .mobil-click-element {
        pointer:cursor;
    }
</script>

 // Then put the class on the element you want to be clickable
 <div class="mobil-click-element">some other html</div>

If you can't edit the css you can put the style directly on the element like so

 <img style="cursor:pointer" ... />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!