gpt4 book ai didi

jquery - 使用JQuery在Head标签中添加元数据

转载 作者:行者123 更新时间:2023-12-03 22:21:14 25 4
gpt4 key购买 nike

我正在尝试在 Head 中插入一个新的元标记,我使用的内容管理系统不允许在 Head 中进行编辑,因此我尝试使用 jQuery 来执行此操作。不幸的是我无法工作。

这是我添加到以下网页的代码:http://www.newcastlegateshead.com

<script type="text/javascript"> 
$("head").append("<meta name=viewport content=width=400, initial-scale=0.45, minimum- scale=0.45/><link rel=apple-touch-icon href=/images/customIcon.png/><meta name=apple-mobile-web-app-capable content=no /><meta name=apple-mobile-web-app-status-bar-style content=black-translucent /><link rel=apple-touch-icon-precomposed href=/images/customIcon.png/> ");
</script>

最佳答案

尝试您的代码

<script type="text/javascript"> 
$(document).ready(function() {
$("head").append("<meta name=viewport content=width=400, initial-scale=0.45, minimum- scale=0.45/><link rel=apple-touch-icon href=/images/customIcon.png/><meta name=apple-mobile-web-app-capable content=no /><meta name=apple-mobile-web-app-status-bar-style content=black-translucent /><link rel=apple-touch-icon-precomposed href=/images/customIcon.png/> ");
});
</script>

$(document).ready(function() {...}) 的缩写形式是:

jQuery(function ($) {
// Your code
})

这将确保您的代码将在onload期间执行.

关于jquery - 使用JQuery在Head标签中添加元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11018638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com