I want to implement custom jQuery in one of the wordpress templates;
I added these lines to functions.php:
function my_custom_script() {
wp_enqueue_script('extra js', get_stylesheet_directory_uri() . '/js/extra.js');
}
add_action('wp_enqueue_scripts', 'my_custom_script');
Then I wanted to see if it works, so I simply added this to my extra.js file:
alert "Hello folks!";
And yup, alert appearing on the screen. Superb!
But if I want to add custom jQuery, let's say I got dic with id="firstBox":
$('#firstBox').click(function() {
$('#firstBox').hide();
})
And nothing happens at all.
How to properly use jQuery in files like these?