WordPress.org

Support

JQuery

  • I have a jquery function that works fine on the home page but won’t work on other pages of the site. I’m just testing functionality for the moment but my Hello World appears on the home page but not on secondary pages.
    When I check the source code on the secondary pages, I’m seeing the links to the google jquery library and my specific jquery file. But the jquery won’t run. Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    @esmi

    Forum Moderator

    Have you enqueued the script correctly?

    Moderator Andrew Nevins

    @anevins

    Use a browser inspector tool and look at the console section.

    Let us know of the errors displayed on pages where the jQuery is not working.

    function sb_scroller_scripts() {
        wp_enqueue_script( 'jquery' );
    	wp_register_script( 'sbscroller', get_template_directory_uri().'/js/jquery.background_stretch.js');
        wp_enqueue_script( 'sbscroller' );
    }    
    
    add_action('wp_enqueue_scripts', 'sb_scroller_scripts');

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]

    error message:

    TypeError: jQuery(“.homee”).backstretch is not a function
    [Break On This Error]

    end = document.cookie.indexOf(“;”, offset)

    esmi

    @esmi

    Forum Moderator

    That’s an error in your javascript.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘JQuery’ is closed to new replies.
Skip to toolbar