• Resolved OoRakha

    (@oorakha)


    Hey all,

    So, first off, I have been searching for a long time for a theme like Make and it’s beautiful and perfect for what I was looking for, so thank you.

    I’m having an issue adding my own jQuery scripts to my child theme. Link to the site is here: dreamtimewebdesign.com

    As you can see on the homepage, there is some text on the main banner image, reading “Websites, Graphics,…” I want to add jQuery so that when people hover over each of these terms, the color changes (Note: I’m not using CSS for this because the ultimate goal is for a menu to appear on the hover, but I’m going one step at a time).

    Here’s what I’ve done thus far:

    Added this code to the child theme functions.php:

    wp_enqueue_script("jQuery"); //Load jQuery
    
    function make_child_scripts() {
    	wp_register_script( 'OoRakha_myscripts', get_stylesheet_directory_uri() . '/js/myscripts.js', array('jquery'), true );
    	wp_enqueue_script( 'OoRakha_myscripts');
    }
    
    add_action( 'wp_enqueue_scripts', 'make_child_scripts' );
    
    ?>

    In the file myscripts.js, which is in make-child/js, I’ve written this:

    var $j = jQuery.noConflict();
    var banner = function() {
    	$j('.banner_hover').click(function() {
    		$j(this).animate({
    		  color: "black"
    		});
    	});
    }
    $j(document).ready(banner);

    And, in the page builder, I have <h3 id="banner_hover">...

    And, it doesn’t work. I’m new to wordpress and I’ve just been learning jQuery the past few days, so any tips or pointers are strongly appreciated.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding custom jQuery in a Make child theme’ is closed to new replies.