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?
Link to the page: http://memories.uvaphotography.com/home/services/
Javascript code I am trying to insert:
<script>
$("#reply-title").hide();
</script>
The reason that you're not seeing your script execute is because jQuery isn't assigned to the
$
variable.When viewing the element inspector console on your page there's a javascript error
When I run the same script via console replacing
$
withjQuery
the#reply-title
is hidden successfully.jQuery in WordPress runs in noConflict mode which means the global
$
shortcut for jQuery isn't available. Replace your code with the following:Inside the document ready wrapper the
$
can be used as an alias for jQuery.