You might have to use get_stylesheet_directory_uri()
instead of get_template_directory_uri()
when you’re referencing files in a child theme.
On a fresh install, I created and activated a child theme of twentyfifteen
called child
and run the following codes:
echo get_stylesheet_directory_uri();
# Output: http://localhost/test1/wp-content/themes/child
echo get_template_directory_uri();
# Output: http://localhost/test1/wp-content/themes/twentyfifteen
Also, If you have tested the JS independently of WordPress, you should know that WordPress loads jQuery in the no conflict mode, that is, you should use jQuery
instead of $
.
So:
$(document).ready(function(){
// JS code
});
Becomes:
jQuery(document).ready(function($){
// JS code
});