我试图用一些简单的jQuery脚本测试我的wordpress页面,但它不起作用。
我在脚本中加载了wp_enqueue_script(\'jquery\');
在里面functions.php
如中所述wordpress guide 但有些东西有问题。
我正在使用FireBug
安装于Firefox 4
如果我查看一下加载的脚本列表,就可以了,但它也会返回错误jQuery is not defined
也
我已经按照noConflict
模式,但对我仍然不起作用:
// 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>
我错在哪里?我试过了this tutorial 而且据说这里没有定义jQuery对象:
// 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\');
});