Enqueue jQuerry: Fatal error: Call to undefined function jQuery() in
-
Hi everyone,
I am currently working on a child-theme for my website, and I would like to enqueue jQuerry to be able to work with the .addClass function.
Here is what I added to my functions.php sheet:
<?php function penscratch_child_scripts() { wp_enqueue_script( 'penscratch-sticky-menu', get_template_directory_uri() . '/js/jquery.js', array(), '1.11.2', false ); add_action( 'wp_enqueue_scripts', 'penscratch_scripts_child' ); } ?>
I want my script to be used on the entire website, so I added the following in my header.php sheet:
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.js"></script>
<?php jQuery(window).scroll(function() { if (jQuery(this).scrollTop() > 1){ jQuery('header').addClass("fixed"); } else{ jQuery('header').removeClass("fixed"); } }); ?>
Once I reach this step and I try to test my code in the browser I get this message:
Fatal error: Call to undefined function jQuery() in C:\Wamp\etc.
plus a table called call stack with a bunch of different info.
I am fairly new at PHP and after spending 4 hours looking for tutorials I cannot figure out how to solve that.
Thank you for your help!
Teddy
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Enqueue jQuerry: Fatal error: Call to undefined function jQuery() in’ is closed to new replies.