- Don’t enqueue your own version of jQuery. You’re just going to cause conflict issues with other plugins and there’s nothing in your script that requires a different version.
- Even if you were, just load the https:// version, there’s no reason to bother checking what your own server is doing.
- Don’t bother checking
!is_admin()
on your enqueue function,wp_enqueue_scripts
doesn’t even run in admin. - Don’t add script tags in templates, use
wp_enqueue_script()
. - The proper way, these days, to get the URL to a theme file is
get_theme_file_uri()
. - When you say “I have used this script just BEFORE the
</body>
tag in my functions.php :”, you don’t actually mean your</body>
tag is in functions.php do you?
Put all together, your code should just be this, in your functions.php file:
function wpse_283386_enqueue_scripts() {
wp_enqueue_script( 'menu-hover', get_theme_file_uri( 'js/menu-hover.js' ), array( 'jquery' ), '', true );
}
add_action( 'wp_enqueue_scripts', 'wpse_283386_enqueue_scripts' );
The only reasons it wouldn’t work after this are:
- The IDs you’re targeting in your script don’t exist.
- The classes you’re adding and removing don’t do anything in your CSS.
/wp-content/themes/{your theme}/js/menu-hover.js
doesn’t exist.