Unable to enqueue jQuery
-
For one reason or another, I am unable to get my script to properly enqueue even though it works (nearly) perfectly embedded in the footer. The script is to allow for the overlapping/hiding of multiple pages on a small user login form on the header. I have attempted various versions of the following enqueue function:
function my_scripts_method() { wp_register_script('login_script', get_template_directory_uri() . '/js/login.js', array('jquery') ); wp_enqueue_script('login_script'); } add_action('wp_enqueue_scripts', 'my_scripts_method');
The login.js file is as follows:
jQuery(document).ready(function() { jQuery(".tab_content_login").hide(); jQuery("ul.tabs_login li:first").addClass("active_login").show(); jQuery(".tab_content_login:first").show(); jQuery("ul.tabs_login li").click(function() { jQuery("ul.tabs_login li").removeClass("active_login"); jQuery(this).addClass("active_login"); jQuery(".tab_content_login").hide(); var activeTab = jQuery(this).find("a").attr("href"); if (jQuery.browser.msie) {jQuery(activeTab).show();} else {jQuery(activeTab).show();} return false; }); });
As I mentioned, I am able to embed this same code in no conflict mode directly in the footer, but I would prefer to be able to keep these files as clean as possible.
Am I performing the enqueue function incorrectly?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Unable to enqueue jQuery’ is closed to new replies.