Javascript does not load Wordpress footer

I recently started to learn Javascript. I am trying to add a small script to the page footer on my Wordpress site. I use the "insert header and footer" plugin. However, the script does not seem to load. I do not think this is a syntax problem, since a similar script works on another site. However, I canโ€™t understand what has changed here. When viewing the built-in script in the chrome inspector, inside the script seems to be just text (not JavaScript color code). Is there something I can do to fix this and run the script?

Link to the page: http://memories.uvaphotography.com/home/services/

Javascript Code I'm trying to insert:

<script> $("#reply-title").hide(); </script> 
+2
source share
2 answers

The reason you are not running your script is because jQuery is not assigned to the $ variable.

When viewing the console of the item inspector, a javascript error appears on your page

  Uncaught TypeError: undefined is not a function 

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

+2
source

jQuery in WordPress works in noConflict mode, which means that the global $ shortcut for jQuery is not available. Replace the code as follows:

 <script> jQuery(document).ready(function($) { $("#reply-title").hide(); }); </script> 

Inside the finished packaging of a document, $ can be used as an alias for jQuery.

+4
source

Source: https://habr.com/ru/post/979555/


All Articles