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
The topic ‘jQuery is not defined when using admin_enqueue_scripts’ is closed to new replies.