我在网站上实现悬停效果时遇到问题。效果在桌面上运行良好。在手机上,图像都正常显示,当我点击它们时,它们会带我到正确的链接。但是当我在浏览器上按回键时,我看到的只是图像替代文本。有人可以建议吗?这是我目前拥有的代码。对于类似问题,我似乎无法在这里找到任何解决方案。谢谢
$(document).ready(function () {
$('.img1')
.mouseover(function () {
$(this).attr("src", "https://cdn.shopify.com/s/files/1/1297/5789/t/3/assets/Easy_Motion_-_Electric_Bicycles_Two.jpg?6314974642385151026");
})
.mouseout(function () {
$(this).attr("src", "https://cdn.shopify.com/s/files/1/1297/5789/t/3/assets/Easy_Motion_-Electric_Bikes.jpg?10135819641956685452");
});
<div class='desktop-4 tablet-full mobile-full'><a href='/home'><img src="https://cdn.shopify.com/s/files/1/1297/5789/t/3/assets/Easy_Motion_-Electric_Bikes.jpg?10135819641956685452" alt="electric bikes by easy motion" class="img1"/></a></div>
最佳答案
只需为移动设备禁用它(mouseenter ecc.. 不起作用)
$(document).ready(function() {
if(!isMobile) {
// your code...
}
});
检查这个问题:What is the best way to detect a mobile device in jQuery?用于检测移动设备或使用 Modernizr 检测是否启用了触摸
关于jquery - 当我点击手机屏幕上的后退按钮时图像消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40871791/