0

I have a small click event that i'm using to play/pause a video html5 tag when i'm on desktop but today i realized that the same event is triggered in mobile browsers aswell and i would like to prevent that from happening

var video = $('#player');
video.on('click', function(e){
    this.paused ? this.play() : this.pause();
});
Emanuel Ones
  • 279
  • 1
  • 9
  • 1
    Maybe you can check the width of the screen (Read here: https://stackoverflow.com/questions/1248081/get-the-browser-viewport-dimensions-with-javascript/18194860) before executing the code with an `IF` condition. – Shidersz Jan 02 '19 at 21:44
  • I agree conditional functionality based on screen width might be the best option, but if you want to detect mobile devices, also see [What is the best way to detect a mobile device in jQuery?](https://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device-in-jquery) – showdev Jan 03 '19 at 03:11

0 Answers0