WordPress.org

Ready to get started?Download WordPress

Forums

JQuery (5 posts)

  1. MTWK-Applied
    Member
    Posted 1 year ago #

    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?

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    Have you enqueued the script correctly?

  3. Andrew
    Forum Moderator
    Posted 1 year ago #

    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.

  4. MTWK-Applied
    Member
    Posted 1 year ago #

    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)

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    That's an error in your javascript.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.