본문 바로가기

Mobile/iOS

[iOS] javascript click event 오류

iOS에서 WebView 이용해서 개발 중 빠르게 터치시 ckick 이벤트가 발생하지 않는 현상이 발생



var bClick = false;
$(static_parent).on("mousedown", element, function () {
  bClick = true;
}).on("mouseup", element, function () { if(bClick) {

bClick = false;

// 실행 코드

}

});


또는


$(static_parent).on('touchstart touchend click', function(evt) {  

if(evt.type == 'touchstart') {

  $(this).data('touch', 1);

  $(this).css('background-color', '#f00');

}

if(evt.type == 'touchend' || evt.type == 'click'){

      if($(this).data('touch')){

          $(this).css('background-color', '#fff');

// 실행 코드

}

$(this).data('touch', 0);

}

});