Enqueued JavaScript is not working

I’ve ecountered many problems while creating my own WordPress Theme and this is not different. Except that I can’t find a solution. I’m good with HTML and CSS, but I know little to nothing from JavaScript and JQuery.

I’m trying to apply the effect from here on my website. I’ll find out whether this code works for me or not.

The problem is this. I’ve copied the HTML in the right place, I’ve copied the CSS in the right place. I’ve also copied the JavaScript to /assets/js/script.js

Using the proper function this script is enqueued in the functions.php file.

function mytheme_scripts() {
wp_enqueue_script( ‘script’, get_template_directory_uri() . ‘/assets/js/script.js’, true );
add_action ( ‘wp_enqueue_scripts’, ‘mytheme_scripts’);

I can see the file apearing in the head of my page but it doesnt seem to work. Now, it can be me adjusting things or editing the code, but according to the JavaScript there should be added a div with the class .code and that doesn’t happen. That’s how I can see that my file is correctly added but is not executing properly or at all.

And for the life of me and my little-known knowledge of JavaScript I can’t figure out why.

Read more here:: Enqueued JavaScript is not working

Leave a Reply

Your email address will not be published. Required fields are marked *