[英]jQuery doesn't recognize function
I have an .js file that has certain functions: 我有一个具有某些功能的.js文件:
$(function(){
function slideDown(class) {
var className = class;
$('.slide_' + className).slideDown('slow', function() {
});
}
});
(And yes i added the .js file in the heading and it's showing in the firebug console.) (是的,我在标题中添加了.js文件,它显示在萤火虫控制台中。)
And i got an link that calls the function: 我得到了一个调用该函数的链接:
<a href="#" onclick="slideDown('.$x.');" class="info">i</a>
But when i press the button my firebug gives the following error: 但是,当我按下按钮时,萤火虫显示以下错误:
ReferenceError: slideDown is not defined
ReferenceError:未定义slideDown
So what am i doing wrong? 那我在做什么错?
您在另一个函数中声明了slideDown
,因此它仅在该函数内部可用,在函数外部进行声明,这样它将具有全局作用域。
There is an error with the variable class
. 变量
class
出错。 Please use another variable name 请使用另一个变量名
Error:
class
is a reserved identifier错误:
class
是保留的标识符
$ x是未定义的,我想这段代码是针对php的
<a href="#" onclick="slideDown('<?=$x?>');" class="info">i</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.