Jquery 与 PC 相比,在移动设备上的行为不同,代码相同

Jquery acting different on mobile compared to PC, with the same code

问题出在我正在开发的网站上

http://balticpremier.sem.lv/en/

(https://www.virustotal.com/#/url/e2f05f0f4d6fde378f3f784c8c331849caef1e556fb1b173e4ac2f5ba521405c/detection)

滚动到底部并查看我们交付的产品部分。它应该在悬停和单击时展开,这在 PC 上没有问题。但是,当通过 phone 访问时,单击时会出现淡入淡出效果,并且逻辑不正确。

这是唯一影响这部分的 JS 在这里:

$('.deliveredCategory').on('click mouseenter mouseleave', function () {
    $(this).find(".expandableClient").toggle();
    $(this).find('.plus-minus-toggle').toggleClass('collapsed');
    $(this).find('.dotHide').toggle();
});

感谢帮助!!

编辑:忘了说淡入淡出效果不是代码的一部分,只发生在移动设备上。这是如何切换();在手机上翻译?无论哪种方式,在移动设备上我也无法在展开后将其关闭。真奇怪。

显然,我正在使用的站点连接了 Cloudflare,并且它之前缓存了我的一部分 JS 代码,这解释了我遇到的问题。我联系了主机管理器,他们刷新了缓存,它再次工作了。

谢谢大家的回答。

好的,找到解决方案了。我真的希望它能让yopu满意,如果不满意,那对不起:)

所以你可以检查设备是否有触摸设备,如果有,则解除绑定鼠标悬停事件。或者您想要的任何其他活动。

var num = 0;
$(".testDiv").on("click mouseover", function() {
  num++;
  $(".testDiv").text(num)
});
if (!!('ontouchstart' in window)) { //check for touch device
  $('.cc').unbind('mouseover');
}
.testDiv {
  background: lightgreen;
  overflow: hidden;
  height: 200px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span>Div below uses "click mouseover"</span>
<div class="testDiv">
  <p>
    Initial text to test whether hovering this works properly. Initial text to test whether hovering this works properly.
  </p>
</div>

希望这就是你想要的。

此致,KJ