0

在表单外单击时,我使用以下内容隐藏 div 和 ovelay div。

以下javascript是:

$(document).mouseup(function (e)
{
  var container = $("#feedbackform");
  var overlay = $("#overlay");

  if (!container.is(e.target) // if the target of the click isn't the container...
    && container.has(e.target).length === 0) // ... nor a descendant of the container
  {
    $('#feedbackform').fadeOut('fast'),
    $('#overlay').fadeOut('fast');
  }
});

这在台式机上运行良好,但在触摸移动设备上却不行。

我猜它与mouseup有关,有什么建议吗?

克雷格。

4

1 回答 1

0

经典事件在移动设备上的工作方式并不完全相同(除了一些事件,如“点击”,这是完全相同的)。

所以现在你有一些名为的移动特定事件touch eventshttps ://developer.mozilla.org/en-US/docs/Web/Guide/Events/Touch_events

所以 touchend 可能是你想要使用的:

$(document).on('mouseup touchend', function (e){

[...]

});
于 2014-06-22T22:36:46.970 回答