Top

Daily Tip: Adding Custom JS to WordPress? Remember jQuery NoConflict Wrappers

May 15, 2010

If you’re adding some extra jQuery to customize your WordPress site and it doesn’t seem to be working, remember that the copy of jQuery that WP loads is in “no conflict” mode. If you’re attempting to use the default jQuery shortcut of $, then you’ll want to wrap it with the following:

jQuery(document).ready(function($) {
    // $() will work as an alias for jQuery() inside of this function
});

This will save you a lot of time beating your head against a wall, wondering why your jQuery isn’t working. ;)

Source: WordPress Codex

Tweet This Post

Comments

Got something to say?

Bottom
Article Archive  |  This site is a historical archive of pressography.com, a WordPress plugin and theme blog that published between 2006 and 2012. It is preserved for reference and is not operated by, affiliated with, or endorsed by its original authors. Nothing here is for sale and no form on this site is active. If you are the original owner and would like this domain returned, please get in touch.