0
(function($) {
    $(document).ready(function(){
        /*$('body').css('position','relative');
        $('body').animate({'left':'-9999px'},3000);*/
        alert('hello');
    });
}(jQuery));

Tried also

$(document).ready(function(){
            /*$('body').css('position','relative');
            $('body').animate({'left':'-9999px'},3000);*/
            alert('hello');
        });

And firebug jumps:

jQuery is not defined
[Detener en este error] }(jQuery)); 

3 Answers 3

1

Are you sure the jQuery library is loaded on your page? The error you're getting implies it isn't. View the source and search for jQuery.

Then try adding this some where in your functions.php (or plugin) file and see if your script works.

<?php
add_action( 'wp_enqueue_scripts', 'wpse30127_enqueue' );
function wpse30127_enqueue()
{
    wp_enqueue_script( 'jquery' );
}
0

try this:

jQuery.noConflict();
jQuery(document).ready(function($) {
   alert("hello");

});
1
  • The error goes: jQuery is not defined [Detener en este error] jQuery.noConflict(); with your code.. Commented Oct 3, 2011 at 15:17
0

If your enqueuing jQuery from WordPress (as you should be) it will be in compatibility mode so you need to call it with jQuery not $. There's a tutorial on Digging into WordPress on how to change this behaviour, which should fix your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.