iphone's safari touchmove event not working

前端 未结 2 816
一整个雨季
一整个雨季 2020-12-08 23:18

i am using jquery and touchmove event but the code is not showing anything in #info

$(\'#movieShow\').bind(\'touchmove\',function(e){                   
             


        
2条回答
  •  悲哀的现实
    2020-12-08 23:39

    It might be as simple as a mis-named DIV id ('#info') but can't tell without seeing everything.

    Try this, and see if you still get no output:

    $('#movieShow').bind('touchmove',function(e){                   
        e.preventDefault();                 
        console.log(e.touches[0].pageX);
    });
    

    (You'll need to turn on Debug Console in MobileSafari)

    UPDATE

    So, from your comment you get an error: 'e.touches' is not an object

    In that case try this (not jQuery specific):

    document.addEventListener('touchmove', function(e) { e.preventDefault(); }, false);
    document.getElementById('movieShow').addEventListener('touchmove',  function(e){
      console.log(e.touches[0].pageX);
    },  false);
    

提交回复
热议问题