jquery - 单击更改元视口(viewport)内容

标签 jquery html css

我试图在点击时更改视口(viewport)内容,以便用户可以在图像加载到模式中时缩放图像,然后在模式关闭时将视口(viewport)内容更改回正常状态。

//button to open the modal and change the viewport content 
$('#product-zoom').on('touchstart', function () {
                    console.log('found html')
                    $('meta[name=viewport]').remove();
                    $('head').append('<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=12, user-scalable=yes">');
            });
//button to close the modal and change the viewport
            $('.btnZoomerClose').on('click', function () {
                console.log('close modal')
                $('head').append('<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">');
            });

出于某种原因,关闭不会将视口(viewport)更改回正常状态。

任何建议或信息都会很棒!

最佳答案

您想将视口(viewport)更改回正常状态,但是您在打开和关闭模态窗口时为视口(viewport)设置了相同的属性..您的意思是要返回

$('head').append('<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">');  

回到

$('meta[name=viewport]')

关于jquery - 单击更改元视口(viewport)内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54464996/

相关文章:

javascript - 使用 jQuery 循环并获取 JSON 数组的键/值对

javascript - 侧边栏 DOM 与 Navbar 重叠,将其从 DOM 中移除

html - 如何告诉谷歌这篇文章是另一篇文章的一部分

html - 为什么 body 元素的背景样式会影响整个屏幕?

php - 当ajax表单无效时,如何在 View 中显示表单错误?

javascript - 如何在 Jquery 中制作不可见的 div 内容?

javascript - 捕获隐藏输入元素 jQuery 的值

php - HTML 中嵌入 PHP 提前结束?

html - div 旁边的 3 行文本问题

html - 有没有办法在悬停时更改 css(样式 ="")?