Be sure to enqueue jQuery first. It comes built in to wordpress but doesn't come pre-activated.
Search your theme's function.php file for "wp_enqueue", if there is a function there already enqueuing scripts add the following line to it..
wp_enqueue_script( 'jquery' );
Otherwise, create your own enqueue scripts function..
// function to enabled (enqueue) scripts in wordpress
function enqueue_scripts() {
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts','enqueue_scripts');
update
Alternatively
You can create a js file with your custom code and enqueue for use site wide.
Create a file named mycustomfunctions.js
Put this in it..
// describe function here
jQuery(function() {
jQuery('.explore > .country').hover(function() {
jQuery(this).parent().toggleClass('hover');
})
jQuery('.explore > .community').hover(function() {
jQuery(this).parent().toggleClass('hover2');
})
});
In your child theme root folder create a new folder, name it 'js'
Put mycustomfunctions.js in js folder
Edit your child themes functions.php to include..
// function to enable (enqueue) scripts in wordpress
function enqueue_scripts() {
wp_enqueue_script('mycustomfunctions', get_stylesheet_directory_uri() . '/js/mycustomfunctions.js', array('jquery') );
}
add_action('wp_enqueue_scripts','enqueue_scripts');
note - no need to enqueue jquery separately as we've listed it as a dependency for mycustomfunctions (see array), wordpress will enqueue jquery automatically because of this required dependency.