Blog » code

how to use jQuery in WordPress June 3, 2011

Depending on motivation, these “how-to’s” may or may not become a regular occurrence. I get asked web questions all the time and instead of having to explain the same thing over and over again, I’d like to just start cataloging my solutions.

I’ll kick things off with a quickie:

You’re trying to use jQuery in your WordPress theme, widget or plugin but you keep getting an error that’s something along the lines of “Result of expression ‘$’ [undefined].”

Chances are, there are other JavaScript libraries being loaded that also uses “$” and it’s fucking up your juice.

Use “.noConflict()” to get your party started.

// Code that uses jQuery's regular "$" can hang out in here.

Filed In: Blog