Javascript 未加载 wordpress 页脚 [英] Javascript not loading wordpress footer

查看:25
本文介绍了Javascript 未加载 wordpress 页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始学习 Javascript.我正在尝试将一个小脚本添加到我的 Wordpress 网站页面的页脚中.我正在使用插入页眉和页脚"插件.但是,脚本似乎没有加载.我不相信这是一个语法问题,因为类似的脚本在不同的站点上工作.但是,我无法弄清楚这里有什么不同.在 chrome Inspector 中查看插入的脚本时,脚本内部似乎只是纯文本(不是彩色的 javascript 代码).我能做些什么来解决这个问题并使脚本运行吗?

I recently started learning Javascript. I am trying to add a small script to the footer of a page on my Wordpress site. I am using the "insert headers and footers" plugin. However, the script does not seem to load. I do not believe it is a syntax issue, since a similar script works on a different site. However, I cannot figure out what is different here. When looking at the inserted script in chrome inspector, inside of the script seems to be just plain text (not colored javascript code). Is there something I can do to fix this and make the script run?

页面链接:http://memories.uvaphotography.com/home/services/

我试图插入的 Javascript 代码:

Javascript code I am trying to insert:

<script>
$("#reply-title").hide();
</script>

推荐答案

您没有看到脚本执行的原因是 jQuery 未分配给 $ 变量.

The reason that you're not seeing your script execute is because jQuery isn't assigned to the $ variable.

在您的页面上查看元素检查器控制台时出现 javascript 错误

When viewing the element inspector console on your page there's a javascript error

Uncaught TypeError: undefined is not a function

当我通过控制台用 jQuery 替换 $ 运行相同的脚本时,#reply-title 被成功隐藏.

When I run the same script via console replacing $ with jQuery the #reply-title is hidden successfully.

这篇关于Javascript 未加载 wordpress 页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆