要在页面中删除AMP(加速移动页面)的政策声明,可以通过以下代码示例来实现:
// 找到政策声明元素
var policyElement = document.querySelector('.amp-policy-statement');
// 如果找到了元素,则从DOM中删除
if (policyElement) {
policyElement.remove();
}
这段代码首先通过document.querySelector方法找到具有类名.amp-policy-statement的元素,然后使用remove方法将其从DOM中删除。
.amp-policy-statement {
display: none !important;
}
这段CSS代码将.amp-policy-statement元素的display属性设置为none,以隐藏该元素。使用!important可以确保该样式优先级最高,以覆盖其他样式。
请注意,这些代码示例仅适用于具有类名.amp-policy-statement的政策声明元素。根据页面的实际结构和元素名称,你可能需要相应地修改代码。
下一篇:AMP可以访问DOM元素吗?