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)); 
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");

});
  • The error goes: jQuery is not defined [Detener en este error] jQuery.noConflict(); with your code.. – Toni Michel Caubet Oct 3 '11 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, privacy policy and cookie policy

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