简体   繁体   中英

jQuery doesn't recognize function

I have an .js file that has certain functions:

$(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.)

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

So what am i doing wrong?

您在另一个函数中声明了slideDown ,因此它仅在该函数内部可用,在函数外部进行声明,这样它将具有全局作用域。

There is an error with the variable class . Please use another variable name

Error: class is a reserved identifier

$ x是未定义的,我想这段代码是针对php的

<a href="#" onclick="slideDown('<?=$x?>');" class="info">i</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM