我只是在单击特定按钮时切换类,当用户单击外部文档时,我想删除该类。如果我将事件更改为在桌面上单击和测试,但在 iPad 上似乎没有任何反应,这可以正常工作。任何人都可以就如何使这项工作提供任何建议吗?
$shoppingIcon.on('click', function(e) {
var $this = $(this);
$this.prev($productInfo).toggleClass('active');
});
$(document).on('touchstart', function() {
$productInfo.removeClass('active');
});