Install jQuery

This topic is: resolved

This topic contains 4 replies, has 2 voices, and was last updated by  benjeeno 10 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #78911

    benjeeno
    Participant
    Post count: 266

    I’m trying to install the following jQuery and by all appearances to me it should work but I can’t get it to work for some reason. Care to see what I may be doing wrong in installing it? The code below is actually not in the referenced site below; I’m working on a copy locally.

    Here is how I’m enqueueing it in the functions.php file:

    
    add_action( 'wp_enqueue_scripts', 'enqueue_headlinesubhead_script' );
    function enqueue_headlinesubhead_script() {
    
    	wp_enqueue_script( 'headline-subhead', get_stylesheet_directory_uri() . '/js/headline_subhead.js', array( 'jquery' ), '1.0.0', true );
    }
    

    Here’s the jQuery in the headline_subhead.js file that I’ve placed in the /js directory.

    
    jQuery(document).ready(function($) {
        $(".headline, .subhead")
    		.fadeIn(3000);
    });
    

    It’s for the headline/subhead text of the homepage, front and center.

    • This topic was modified 10 months, 2 weeks ago by  benjeeno.
    • This topic was modified 10 months, 2 weeks ago by  benjeeno. Reason: clarification
    • This topic was modified 10 months, 2 weeks ago by  benjeeno.
    • This topic was modified 10 months, 2 weeks ago by  benjeeno. Reason: clarification
    http://thekennedybook.com/marketingdev
    #78980

    Sridhar Katakam
    Participant
    Post count: 1050

    Does that jQuery work as intended on a static HTML page?

    Implementation wise, I see no issues. You can view the source and see if the headline_subhead.js file is being loaded or not. I tested the same on a test site and it’s fine. I constructed a simple HTML page to test, ensured that jQuery is working fine but fadeIn does not work. So it is a problem with the jQuery syntax/code itself rather than anything with WordPress and enqueuing.


    #79051

    benjeeno
    Participant
    Post count: 266

    Yes, here’s where I got the jQuery from, the red text that pops in at the top of the page. I have modified it a bit for what I’m trying to seek through this post. http://bensiegfried.com/jquery/news.html

    • This reply was modified 10 months, 2 weeks ago by  benjeeno.
    • This reply was modified 10 months, 2 weeks ago by  benjeeno.
    #79056

    Sridhar Katakam
    Participant
    Post count: 1050

    Just add the following in your child theme’s style.css and you will be good to go.

    .headline, .subhead {
    	display: none;
    }

    #79057

    benjeeno
    Participant
    Post count: 266

    Alright, thanks!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.