I have implemented some JavaScript on my site but I keep getting the following error messages:

Uncaught ReferenceError: jQuery is not defined

and

Uncaught SyntaxError: Unexpected token <

This is the JavaScript that I am using in the header.php:

 <script type="text/javascript" src="/test/wp-content/themes/child/script/jquery.jcarousel.min.js"></script> <script type="text/javascript" src="/test/wp-content/themes/child/script/jquery.scrollTo.js"></script> <script type="text/javascript" src="/test/wp-content/themes/child/script/jquery.backgroundPosition.js"></script> <script type="text/javascript" src="/test/wp-content/themes/child/script/scripts.js"></script> <script type="text/javascript" src="/test/wp-content/themes/child/script/jquery.cycle.lite.js"></script> <script type="text/javascript" src="/test/wp-content/themes/child/script/jquery.accordian.js"></script> <script type="text/javascript"> jQuery(document).ready(function () { jQuery('#contentGallery').cycle({ fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc... }); }); </script> </head> <body <?php body_class(); ?>> <div> <header> <hgroup> <h1><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1> <h2><?php bloginfo( 'description' ); ?></h2> </hgroup> <?php // Check to see if the header image has been removed $header_image = get_header_image(); if ( ! empty( $header_image ) ) : ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <?php // The header image // Check if this is a post or page, if it has a thumbnail, and if it's a big one if ( is_singular() && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ) ) && $image[1] >= HEADER_IMAGE_WIDTH ) : // Houston, we have a new header image! echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' ); else : ?> <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" /> <?php endif; // end check for featured image or standard header ?> </a> <?php endif; // end check for removed header image ?> <nav> <div> <ul> <li><a href="#contact"></a></li> <li><a href="#context"></a></li> <li><a href="#artScience"></a></li> <li><a href="#home"></a></li> </ul> <div> </div> </div> <div> <div> <div> </div> </div> </div> </div> <div> <div> <img src="Images/Gallery/london.jpg" width="1200" height="550" alt="London" /> <img src="Images/Gallery/singapore.jpg" width="1200" height="550" alt="Singapore" /> <img src="Images/Gallery/geneva.jpg" width="1200" height="550" alt="Geneva" /> </div> <div> </div> <div> <div> <div> <div> <span>GMR</span> <div> </div> <div> <p> very long text 1 </p> </div> </div> </div> <div> <div> <div> <span>About Us</span> <div> <p> Insert text here. </p> </div> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle" height="100%"> <a href="#">The Art</a> </td> <td valign="middle" height="100%"> <a href="#">The Science</a> </td> </tr> </table> </div> <div> <span>The Art</span> <div> <a href="#">Sensitivity</a> <div> <p>very long text 2</p> </div> <div> </div> <a href="#">Creativity</a> <div> <p>very long text 3</p> </div> <div> </div> <a href="#">Intuition</a> <div> <p>very long text 4</p> </div> <div> </div> <a href="#">Judgment</a> <div> <p>very long text 5</p> </div> </div> <a href="#">The Science</a> </div> <div> <span>The Science</span> <div> <a href="#">Methodology</a> <div> <p>very long text 6</p> </div> <div> </div> <a href="#">Research</a> <div> <p>very long text 7</p> </div> <div> </div> <a href="#">Team Approach</a> <div> <p>very long text 8</p> </div> <div> </div> <a href="#">Sharing Information</a> <div> <p>very long text 9</p> </div> </div> <a href="#">The Art</a> </div> </div> </div> <div> <div> <span>Expertise</span> <div> <a href="#">Expertise</a> <div> <p>very long text 10</p> </div> <div> </div> <a href="#">Business Context</a> <div> <p>very long text 11</p> </div> <div> </div> <a href="#">Cultural Context</a> <div> <p>very long text 12</p> </div> <div> </div> <a href="#">Candidate Context</a> <div> <p>very long text 13</p> </div> <div> </div> <a href="#">Financial Context</a> <div> <p>very long text 14</p> </div> <div> </div> <a href="#">Service Context </a> <div> <p>very long text 15</p> </div> </div> </div> </div> <div> <div> <span>Contact</span> <div> <h2> Tel: +44(0)1234 567 890</h2> <h3> Email: <a href="mailto:info@info">info@info</a></h3> </div> </div> </div> </div> </div> <h3><?php _e( 'Main menu', 'twentyeleven' ); ?></h3> <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?> <div><a href="#content" title="<?php esc_attr_e( 'Skip to primary content', 'twentyeleven' ); ?>"><?php _e( 'Skip to primary content', 'twentyeleven' ); ?></a></div> <div><a href="#secondary" title="<?php esc_attr_e( 'Skip to secondary content', 'twentyeleven' ); ?>"><?php _e( 'Skip to secondary content', 'twentyeleven' ); ?></a></div> <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?> </nav><!-- #access --> </header><!-- #branding --> 

This is the code I am using in the footer.php:

<div> <ul> <li><a href="#home">Home</a></li> <li><a href="#artScience">About Us</a></li> <li><a href="#context">Approach</a></li> <li><a href="#contact">Expertise</a></li> </ul> </div> 
4

5 Answers

jQuery needs to be the first script you import. The first script on your page

<script type="text/javascript" src="/test/wp-content/themes/child/script/jquery.jcarousel.min.js"></script> 

appears to be a jQuery plugin, which is likely generating an error since jQuery hasn't been loaded on the page yet.

7

you need to put it after wp_head(); Because that loads your jQuery and you need to load jQuery first and then your js

3

In my case, the error occurred because I was using the wrong version of jquery.

<script src=""></script> 

I changed it to:

<script src=""></script> 

set this jquery min js

script src="" 

in wp-admin/admin-header.php

3

For one, you don't seem to be including jQuery itself in the header but only a bunch of plugins. As for the '<' error, it's impossible to tell without seeing the generated HTML.