And jQuery script “js-custom.js” when website is loaded, jQuery file location: “YourTheme/js/js-custom.js”
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 );
jQuery file location: “YourTheme/js/js-custom.js”
jQuery(document).ready(function(){
});
When jQuery is used for WordPress script must use jQuery instead of $ sign.