Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I see that on every page Wordpress is loading in jquery, how do I go about using that jquery as it keeps telling me that it doesn't recognize $ or $noConflict(); - I'm trying to add some jquery under wp_head().

share|improve this question
    
You could start by checking the Codex: codex.wordpress.org/Function_Reference/… –  s_ha_dum Jul 29 '13 at 17:08
add comment

1 Answer

up vote 2 down vote accepted

The jQuery object is jQuery rather than $. See noConflict wrappers in wp_enqueue_script for some examples.

jQuery(document).ready(function($) {
    // Inside of this function, $() will work as an alias for jQuery()
    // and other libraries also using $ will not be accessible under this shortcut
});
share|improve this answer
    
I can't make $ universal? I have to keep wrapping my custom JS around the alias. –  Howdy_McGee Jul 29 '13 at 17:47
    
you could reassign it via $ = jQuery;, but you'll only introduce potential conflicts, and as you can see from the example above you only need to reference jQuery for the ready function and pass the $ as argument, where you can freely use $ within. –  Milo Jul 29 '13 at 18:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.