Add custom jQuery script to WordPress theme

How to add custom jQuery script to WordPress theme ?

Code for functions.php to add jQuery script from file to theme directory and js folder:

function add_js_for_theme() {
wp_enqueue_script( 'js-custom', get_stylesheet_directory_uri() . '/js/js-custom.js');
}

add_action( 'wp_enqueue_scripts', 'add_js_for_theme', 10 );

And jQuery script “js-custom.js” when website is loaded:

File location: “YourTheme/js/js-custom.js”

jQuery(document).ready(function(){

});

When jQuery is used for WordPress script must use jQuery instead of $ sign.

Add custom jQuery script to WordPress theme