Try two things –
1. Link your js using wp_enqueue_script
action as under :
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function theme_name_scripts() {
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array('jquery'), '', true);
}
Third parameter in wp_enqueue_script() function will make sure jquery is loaded before your current js file.
-
Inside your js file, replace
$
withjQuery
as :jQuery(document).ready(function(){console.log(“scriptLoaded”);
});