编辑:我知道它的工作...加载jquery库我认为jQuery的工作原理就像JavaScript,而无需导入任何东西。对不起,我不想浪费你的时间。jQuery不起作用| WordPress的顶级菜单
//
此它使用jQuery来固定在IE6显示顶部菜单的(悬停效果)正在WordPress插件。
我想要的是在消除插件需求的同时在主题中实现功能。
的错误,如果我在<head>
部分把这部分
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#access li').mouseover(function() {
$(this).find('ul').show();
});
$('#access li').mouseleave(function() {
$(this).find('ul').hide();
});
$('#access li ul').mouseleave(function() {
$(this).hide();
});
});
</script>
我正在为Uncaught ReferenceError: jQuery is not defined
,所以我发现,最有可能的问题是,JS被加载在我的代码运行。
我曾经在网上找到的解决方案,并包裹着我的代码,在此
$(document).ready(function() {
//my code here
});
而且尝试了out.Now我得到两个错误。
Uncaught ReferenceError: $ is not defined
Uncaught ReferenceError: jQuery is not defined
看错误后它更清晰,但仍然不知道为什么没有工作
//
我得到它的工作通过加载jQuery库从http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js我认为jQuery的作品像JavaScript,而无需输入任何东西; d
WordPress的插件的源代码:
<?php
/**
* Plugin Name: Twentyten IE6 Menus
* Author: Sara Cannon
* Author URI: http://sara-cannon.com
* Description: Make the menu drop down in IE6 (if you care about that sort of thing)
* Version: 1.0
* License: GPL2
*/
function sara_twentyten_ie6_menus_enqueue() {
wp_enqueue_script('jquery');
}
add_action('after_setup_theme', 'sara_twentyten_ie6_menus_enqueue');
function sara_twentyten_ie6_menus_script() {
?>
<!--[if lte IE 6]>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#access li').mouseover(function() {
$(this).find('ul').show();
});
$('#access li').mouseleave(function() {
$(this).find('ul').hide();
});
$('#access li ul').mouseleave(function() {
$(this).hide();
});
});
</script>
<![endif]-->
<?php
}
add_action('wp_footer', 'sara_twentyten_ie6_menus_script');
在firebug JS错误?你手动链接jQuery?这个问题很混乱。 – Bosworth99