WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using wp_enqueue_script to do this. If I try to do something else lets say popup a dialog, it works but the code below does not. Can someone tell me the problem. thanks.

var $j = jQuery.noConflict();
    var mouseLastYPos = null;
            if (e.pageY < mouseLastYPos && e.pageY <= 2){


        mouseLastYPos = e.pageY;

here is a working demo of this code on a static page. when you move you mouse to the top of the page some text appears. http://jsfiddle.net/bmHbt/

share|improve this question
most likely a css error with your WordPress layout. If you don't post your WordPress code it's going to be hard to help. – BandonRandon Apr 27 '12 at 19:51
up vote 4 down vote accepted

The jQuery library included with WordPress loads in "no conflict" mode. This is to prevent compatibility problems with other javascript libraries that WordPress can load.

In order to use the default jQuery shortcut of $, you can use the following wrapper around your code:

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

That wrapper will cause your code to be executed when the page finishes loading, and the $ will work for calling jQuery. If, for some reason, you want your code to execute immediately (instead of waiting for the DOM ready event), then you can use this wrapper method instead:

(function($) {
    // $() will work as an alias for jQuery() inside of this function
share|improve this answer

Your Answer


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.