Title: Using wp_enqueue_script to use Jquery
Last modified: February 29, 2020

---

# Using wp_enqueue_script to use Jquery

 *  [accend4web](https://wordpress.org/support/users/accend4web/)
 * (@accend4web)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/using-wp_enqueue_script-to-use-jquery/)
 * I have created a small jquery function which I have placed in a general.js file
   inside the child theme folder, and have used enque in the functions.php file 
   but I still cant get it to work.
 * This is inside functions.php
 *     ```
       function my_assets() {
       	wp_enqueue_script( 'parent', get_stylesheet_directory_uri() . 'https://www.mysite.co.uk/little-stove-company/wp-content/themes/twentytwenty-child/js/general.js', array( 'jquery' ) );
       }
       ```
   
 * Then inside my general.js file I have this
 *     ```
       jQuery(document).ready(function( $ ) {	
       	$('.post-85.modula-items.img.pic').each( function() {
           var $img = $(this),
               href = $img.attr('/newpage');
           $img.wrap('<a href="' + href + '" class="link"></a>');
       	});	
       });
       ```
   
 * Then when I look in console on the page above I get this issue.
    `Loading failed
   for the <script> with source “https://www.mysite.co.uk/little-stove-company/wp-
   content…wp-content/themes/twentytwenty-child/js/general.js?ver=5.3.2”.`
 * Im noty sure what is broken and why its not working.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fusing-wp_enqueue_script-to-use-jquery%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [6 years, 2 months ago](https://wordpress.org/support/topic/using-wp_enqueue_script-to-use-jquery/#post-12494592)
 * should be
 * `wp_enqueue_script( 'parent', get_stylesheet_directory_uri() . '/js/general.js',
   array( 'jquery' ) );`
 * assuming that js is a subdirectory of your child theme.
    -  This reply was modified 6 years, 2 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  Thread Starter [accend4web](https://wordpress.org/support/users/accend4web/)
 * (@accend4web)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/using-wp_enqueue_script-to-use-jquery/#post-12494690)
 * Ah cool, yes the error has gone now. Just have to work out why the rest of my
   script isnt working now.
 * Thank you
 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/using-wp_enqueue_script-to-use-jquery/#post-12495024)
 * Just so it’s clear: using `get_stylesheet_directory_uri()` will give you the 
   child theme directory. So your script handle probably shouldn’t be ‘parent’.
 * And in your script, what are you trying to do with `href = $img.attr('/newpage');`?
   Attribute names can’t have slashes.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Using wp_enqueue_script to use Jquery’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [Joy](https://wordpress.org/support/users/joyously/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/using-wp_enqueue_script-to-use-jquery/#post-12495024)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
