Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
(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)); 
share|improve this question

3 Answers 3

up vote 1 down vote accepted

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' );
}
share|improve this answer

try this:

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

});
share|improve this answer
    
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

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.

share|improve this answer

Your Answer

 
discard

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.