jQuery is not defined error
-
I added this code to my child functons.php:
‘// enqueue jquery
function load_jquery() {
wp_enqueue_script( ‘jquery’ );
}
add_action( ‘wp_enqueue_scripts’, ‘load_jquery’ );// add custom javascript file
function load_scripts(){
wp_register_script(‘topline’, get_stylesheet_directory_uri() . ‘/script/topline.js’, array(‘jquery’), false);
wp_enqueue_script(‘topline’);
}
add_action(‘wp_enqueue_scripts’, ‘load_scripts’);’In my child header.php I added this:
‘<script type=’text/javascript’ src=”<?php echo get_stylesheet_directory_uri(); ?>/script/topline.js”></script>’
I have cleared my cache and deactivated all of my plugins. The only result was more reference errors. I managed to get WP to find my topline.js file in my child theme folder. I did not do <script>etc.jQuery</script> in my child header.php because I thought jQuery came with WP. Please tell me what I am doing wrong. Thank you. P.S. Sorry the post is so long.
- The topic ‘jQuery is not defined error’ is closed to new replies.