• Resolved etespey

    (@etespey)


    I’m testing out some jquery css effects on a specific wordpress page but nothing seems to be working. I’m wanting to take on box and ‘grow’ it while changing its color; another box with explode when clicked on. I’ve checked the wordpress codex pages and tried their examples but those don’t work either. Here is the code placed in my functions.php file:

    //CREATE JQUERY EFFECTS
    function my_init() {
    		wp_deregister_script('jquery');
    		wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2', true);
    		wp_enqueue_script('jquery');
    
    		// load a JS file from my theme: js/theme.js
    		wp_enqueue_script('my_script', 'https://www.espeykreativedesigns.com/webauthoring/wp-content/themes/pagelines-template-theme/scripts/jqeffects.js', array('jquery'),  true);
    }
    add_action('init', 'my_init');

    The web page is https://espeykreativedesigns.com/webauthoring/web-2-0-applications/
    The red and blue boxes in the middle of the page are the ones that aren’t working.

Viewing 1 replies (of 1 total)
  • Please read the Codex article on wp_enqueue_script.

    Why would you deregister the built in jQuery for a version that was released over 4 years ago? Please just use the version of jQuery bundled with WordPress. It will always be up to date and other plugins rely on it to work properly.

    The correct hook to use for your enqueue function is wp_enqueue_scripts.
    Your ‘my_script’ file is returning a 404 error which is probably why nothing is working.

    function my_load_js() {
        wp_enqueue_script( 'my_script', get_stylesheet_directory_uri(). '/scripts/your-script.js', array( 'jquery' ), true );
    }
    add_action( 'wp_enqueue_scripts', 'my_load_js' );
Viewing 1 replies (of 1 total)
  • The topic ‘Creating jquery effects on a page’ is closed to new replies.