I thought it was worth mentioning that you can do this with pure CSS. This is probably not a good idea, because neither IE10 nor Opera Mobile support it. But this can be done, and in the future it will probably be better than with JavaScript. Or, if you are talking only about the iPhone and iPad, this method will work very well. Here is an example in CodePen .
The code is simple:
.notouch { pointer-events: none; }
Just give the notouch class any image you want to use.
If you want to do this for each image on the page, do the following:
img { pointer-events: none; }
And I have to give a mandatory talk about use. By doing this, you override the default functionality that people expect there all the time. This makes it a really bad experience for you to turn off something like this if you donβt have a really, really good reason. So please make sure you do this.
Edit
To get rid of a magnifying glass, use this code:
.notouch { pointer-events: none; -webkit-user-select:none; }
If the -webkit-user-select parameter is set to "none", you donβt even need to disable pointer events, but I'm not so sure. I also updated CodePen.
source share