Javascript 未捕获类型错误:未定义不是菜单中的函数
我发现了一个我的站点的菜单示例,其中包含以下javascriptJavascript 未捕获类型错误:未定义不是菜单中的函数,javascript,jquery,Javascript,Jquery,我发现了一个我的站点的菜单示例,其中包含以下javascript jQuery.fn.initMenu = function() { return this.each(function(){ var theMenu = $(this).get(0); $('.acitem', this).hide(); $('li.expand > .acitem', this).show();
jQuery.fn.initMenu = function() {
return this.each(function(){
var theMenu = $(this).get(0);
$('.acitem', this).hide();
$('li.expand > .acitem', this).show();
$('li.expand > .acitem', this).prev().addClass('active');
$('li a', this).click(
function(e) {
e.stopImmediatePropagation();
var theElement = $(this).next();
var parent = this.parentNode.parentNode;
if($(parent).hasClass('noaccordion')) {
if(theElement[0] === undefined) {
window.location.href = this.href;
}
$(theElement).slideToggle('normal', function() {
if ($(this).is(':visible')) {
$(this).prev().addClass('active');
}
else {
$(this).prev().removeClass('active');
}
});
return false;
}
else {
if(theElement.hasClass('acitem') && theElement.is(':visible')) {
if($(parent).hasClass('collapsible')) {
$('.acitem:visible', parent).first().slideUp('normal',
function() {
$(this).prev().removeClass('active');
}
);
return false;
}
return false;
}
if(theElement.hasClass('acitem') && !theElement.is(':visible')) {
$('.acitem:visible', parent).first().slideUp('normal', function() {
$(this).prev().removeClass('active');
});
theElement.slideDown('normal', function() {
$(this).prev().addClass('active');
});
return false;
}
}
}
);
});
};
$(document).ready(function() {$('.menu').initMenu();});
但我总是得到这个错误uncaughttypeerror:undefined不是最后一行的函数
$(document).ready(function() {$('.menu').initMenu();});
请帮帮我,我不知道该怎么办
下面是我如何连接jquery的
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="menu.js" type="text/javascript"></script>
您是否包括jQuery?你能把你的HTML放在这里吗?试着使用最新的jquery。我更新了我的问题,我使用jquery 1.4.2JSFIDLE会有所帮助。你使用的是一个有缺陷的4年版jquery,将近5年。是时候咬紧牙关升级了。