WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How do I get external jquery scripts working?? (5 posts)

  1. rugbert
    Member
    Posted 3 years ago #

    Ok, so Ive tried using a number of jquery plugins (NON wordpress plugins) like table sorter, jquery tools, and greybox ect and I cant get any of them to work.

    Firefox's error console keeps giving me stuff like:

    Error: jQuery(".myTable").tablesorter is not a function

    Here is my code

    <?php
    wp_head();
    ?>
    
    <script type="text/javascript" src="<?php get_bloginfo('stylesheet_directory'); ?>/table.js"></script>
    
    <script type="text/javascript">
    jQuery(document).ready(function()
        {
            jQuery(".myTable").tablesorter();
        }
    );
    </script>

    So is WP not seeing me link to the js file?

    oh and

    jQuery(document).ready(function($)
        {
            $(".myTable").tablesorter();
        }
    );

    doesnt work either! ARRRG I jsut want to use my own jquery plugins!

  2. Darrell Schauss
    Member
    Posted 3 years ago #

    Put <?php wp_enqueue_script("jquery"); ?> before the wp_head to load up the jquery.

    I always pull up this tutorial when dealing with jquery on wordpress.
    http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/

    Edit: beat me too it =]

  3. rugbert
    Member
    Posted 3 years ago #

    Ahhh cool. Got it, thanks!

  4. mirsasha
    Member
    Posted 3 years ago #

    So that worked for you? I'm going bonkers trying to figure this out. I *think* I have it right...`<?php wp_enqueue_script('jquery');
    wp_head(); ?>
    <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/scrollable.js"></script>
    <script type="text/javascript">
    jQuery(document).ready(function(){
    // initialize scrollable
    jQuery("div.scrollable").scrollable({
    vertical:true,
    size: 3
    });
    </script>`

    This doesn't work. If, however, I use a version of the scrollable jQuery Tool library that includes jQuery itself, it does work.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.