I read the Codex and a few blog posts about using jQuery in WordPress, and its very frustrating. I\'ve got as far as loading jQuery in functions.php
file, but a
You can add jQuery or javascript in theme's function.php file. The code is as below :
add_action( 'wp_enqueue_scripts', 'add_my_script' );
function add_my_script() {
wp_enqueue_script(
'your_script_name', // your script unique name
get_template_directory_uri().'/js/your-script.js', //script file location
array('jquery') //lists the scripts upon which your script depends
);
}
For more detail visit this tutorial : http://www.codecanal.com/add-simple-jquery-script-wordpress/