admin管理员组文章数量:1394099
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 = ".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.
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/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.
Share Improve this question edited Feb 21, 2020 at 21:56 elpretentio asked Feb 21, 2020 at 21:48 elpretentioelpretentio 33 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 3jQuery is case-sensitive.
Try replacing all instances of JQuery
with jQuery
.
本文标签: javascriptJQuery not loading
版权声明:本文标题:javascript - JQuery not loading 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744724874a2621904.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
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. – Howdy_McGee ♦ Commented Feb 21, 2020 at 21:56/* OceanWP JS */
. You'll need to contact the theme developers for a solution. – Howdy_McGee ♦ Commented Feb 21, 2020 at 22:10jQuery
. – Howdy_McGee ♦ Commented Feb 21, 2020 at 22:33