Title: jQuery is not defined when using admin_enqueue_scripts
Last modified: August 22, 2016

---

# jQuery is not defined when using admin_enqueue_scripts

 *  Resolved [giwrgos88](https://wordpress.org/support/users/giwrgos88/)
 * (@giwrgos88)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/jquery-is-not-defined-when-using-admin_enqueue_scripts/)
 * Hello everyone, I’m working on a plugin and I’m looking for a help about an issue
   that I have. Basically I have created a function inside the index file of my 
   plugin which contains a javascript code. This function i want to use it only 
   in a specific page inside the admin page that why i use the admin_enqueue_scripts.
 * `add_action('admin_enqueue_scripts','my_javascript_code')`
 * The problem that I have is that on the console page when I load the page shows
   the following message “Uncaught ReferenceError: jQuery is not defined” but the
   code is working fine.
 * Here is my code
 *     ```
       function menu_options()
       {
           echo '<script type="text/javascript">
       jQuery(document).ready(function() {
           jQuery(".level2 li").hover(function () {
   
               jQuery(this).append("<li class="menu_options">hello</li>")
           }, function () {
   
               jQuery(this).children(".menu_options").remove();
           })
           });
           });
       </script>';
       }
       ```
   
 * What i’m doing wrong? Also how i can call this function only in a specific page?
 * Thank you

Viewing 1 replies (of 1 total)

 *  Thread Starter [giwrgos88](https://wordpress.org/support/users/giwrgos88/)
 * (@giwrgos88)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/jquery-is-not-defined-when-using-admin_enqueue_scripts/#post-5424443)
 * Ok i found the solution. I have created an js file where i copy/paste the code
   there and removed the <script> tags. then using the following code i’m calling
   the ajax file
 *     ```
       function menu_options() {
           wp_enqueue_script('menu_option_ajaxscript', AJAXACTIONS.'/il_menu/il_menu_admin/ajax/menu_ajax.js', array('jquery'));
           wp_localize_script( 'menu_option_ajaxscript', 'menu_option_ajaxscript', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
       }
   
       add_action('admin_enqueue_scripts', menu_options);
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘jQuery is not defined when using admin_enqueue_scripts’ is closed to 
new replies.

## Tags

 * [admin_enqueue_scripts](https://wordpress.org/support/topic-tag/admin_enqueue_scripts/)
 * [jQuery is not defined](https://wordpress.org/support/topic-tag/jquery-is-not-defined/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [giwrgos88](https://wordpress.org/support/users/giwrgos88/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/jquery-is-not-defined-when-using-admin_enqueue_scripts/#post-5424443)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
