我正在尝试在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>
Run Code Online (Sandbox Code Playgroud)
the*_*dox 15
试试你的代码
<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>
Run Code Online (Sandbox Code Playgroud)
简称$(document).ready(function() {...})是:
jQuery(function ($) {
// Your code
})
Run Code Online (Sandbox Code Playgroud)
这将确保您的代码将在执行期间执行onload.
| 归档时间: |
|
| 查看次数: |
25797 次 |
| 最近记录: |