• I am trying to get this script (found from this webpage https://docs.jquery.com/Tutorials:Zebra_Striping_Made_Easy) to work:

    jQuery(document).ready(function($){
    $(".stripeMe tr").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");});
    $(".stripeMe tr:even").addClass("alt");
    });

    jQuery is enqueued and another jQuery script is running further down the page. I have the nonconflict/$ wrapper on as you can see, yet I get only “jQuery is not defined” error. The page has no HTML errors. I have this script running successfully on another site. WordPress is updated to 3.0.1.

    I have tried calling script as separate file and with full script in the header. I have checked and made sure there is no space at start of the script or the lines within it.

    I have disabled all plugins (no difference) and reinstalled wp-includes and also wp-includes/js by over-writing as well as deleting and then uploading. Currently only “Q and A” plugin is activated.

    I have tried enqueueing jQuery and the script in functions.php.

    Nothing works… I don’t write javascript, and have spent most of today on this. What else can I look for?

Viewing 1 replies (of 1 total)
  • Thread Starter Moodles

    (@moodles)

    OK I just got it working, by moving the script below

    <?php wp_head(); ?>

    On the codex page for wp_enqueue_script, it says this:

    Note that you have to enqueue your script before wp_head is run, even if it will be placed in the footer.

    but that means (I just figured out) jquery is enqueued AFTER the script, because if I look at the source for the page, the WP-injected header lines show this line

    <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js?ver=1.4.2'></script>

    in that block of head meta etc.

    This is not completely resolved, as I hope someone can explain the codex instruction, or am I interpreting it incorrectly?

    And I thought wp_head() had to go just before the body tag? Or it can go anywhere in the head?

Viewing 1 replies (of 1 total)
  • The topic ‘jquery not defined – enqueued, wrapped, what else to do?’ is closed to new replies.