Custom jQuery not loading

I am trying to add a custom jQuery script to the theme function using this command

function celeb_js() {
	wp_enqueue_script( 'celeb', get_stylesheet_directory_uri().'/js/celeb.js', array('jquery'), 'null', true );
}

After using inspector on page load the script does load, however it is loading and firing before jQuery gets loaded. I have attached my jquery script below.


$( document ).ready(function() {
	$("a[title=\"auctions-menu\"]").insertAfter('.sub-links');
	$(".nav-ad").appendTo('.sub-links').addClass('open');
});

If you are using this code via Child Theme then try it like this instead:

function celeb_js() {
	wp_enqueue_script( 'celeb', get_stylesheet_directory_uri().'/js/celeb.js', array('jquery'), false, true );
}
add_action( 'wp_enqueue_scripts', 'celeb_js' );

You need to hook this function to wp_enqueue_scripts in order to make it work properly.

Let me know if this helps.