How can I recognize touch events using jQuery in Safari for iPad? Is it possible?

前端 未结 8 1915
抹茶落季
抹茶落季 2020-11-22 13:09

Is it possible to recognize touch events on the iPad\'s Safari browser using jQuery?

I used mouseOver and mouseOut events in a web application. Are there any simila

8条回答
  •  长情又很酷
    2020-11-22 13:18

    You can use .on() to capture multiple events and then test for touch on the screen, e.g.:

    $('#selector')
    .on('touchstart mousedown', function(e){
      e.preventDefault();
      var touch = e.touches[0];
      if(touch){
        // Do some stuff
      }
      else {
        // Do some other stuff
      }
    });
    

提交回复
热议问题