点击时更改了元视口内容

时间:2019-01-31 16:25:05

标签: jquery html css

我正在尝试更改单击时的视口内容,以便用户可以在将图像加载到模式中时捏住缩放图像,然后在模式关闭时将视口内容恢复为正常。

//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">');
            });

由于某种原因,关闭操作不会将视口恢复为正常状态。

任何建议或信息都很棒!

1 个答案:

答案 0 :(得分:0)

您想将视口改回正常状态,但是在打开和关闭模态时为视口设置了相同的属性。您是否要返回

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

返回

$('meta[name=viewport]')

相关问题