I'm trying to test my wordpress page with some simple jQuery script but it won't work.
I've loaded the script with wp_enqueue_script('jquery');
in functions.php
as explained in the wordpress guide but something's buggy.
I'm testing the page using FireBug
installed in Firefox 4
and if I take a look to the loaded scripts list it's all ok, but it also return me the error jQuery is not defined
too.
I've followed the instructions on the noConflict
mode but it still won't work for me:
// functions.php
<?php
function init_scripts () {
if (!is_admin()) {
wp_enqueue_script('jquery');
}
}
add_action('init', 'init_scripts');
?>
// header.php
<script type="text/javascript">
(function($) {
$(document).ready(function() {
alert('hello?');
});
}(jQuery));
</script>
Where I'm wrong?
I've tried this tutorial too and it's says jQuery object is not defined here:
// jquery from ajax.googleapis.com is correctly loaded
$j=jQuery.noConflict(); // firebug says jQuery is not defined by here
$j(document).ready(function(){
alert('test');
});