I am trying to load a custom script in my WP site, and when I inspect the page it says
Uncaught ReferenceError: JQuery is not defined .
I've loaded the scripts as so in the functions.php file:
function custom_scripts() {
wp_enqueue_script('custom_js', get_stylesheet_directory_uri() . '/js/custom_js.js', array('jquery'), '1.11.0', false );
}
add_action( 'wp_enqueue_scripts', 'custom_scripts', 10 );
The script I'm trying to load is located in the child theme js folder: /wp-content/themes/oceanwp-child/js/custom_js.js
I also manually loaded JQuery in the parent theme header.php file and when I view the page source it was already loading in the footer anyway under Ocean WP Scripts.
Just for a clear reference, this is the script I am trying to load (as a test):
alert('ALERT');
console.log('HELLO');
JQuery(document).ready(function() {
var imageURL = "http://www.kamerake.com/Wordpress/wp-content/uploads/2020/02/strada-av-3-alpha.png";
var noimageURL = " ";
JQuery("p").mouseover(function() {
JQuery("body").css("background-image", "url(" + imageURL + ")");
});
JQuery("p").mouseout(function() {
JQuery("body").css("background-image", "url(" + noimageURL + ")");
});
});
The alert and console.log of course load without any issue.
The only plugins I have activated on WP are Child Theme Configurator, Elementor, Oceans Extra, Elementor Addons, and WP Forms Lite.
I've deactivated all of them but that made no difference.
Any help would be appreciated. Thanks.
wp_head()
andwp_footer()
in the header.php and footer.php files respectively? If you've overwritten either file in your child theme, those 2 functions need to be in there, otherwise they need to be in the parent themes files./* OceanWP JS */
. You'll need to contact the theme developers for a solution.jQuery
.