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?
3 Answers 3
You are declaring slideDown in another function so it is only available inside that function, declare it outside the function so it will have global scope.
Comments
There is an error with the variable class. Please use another variable name
Error:
classis a reserved identifier
1 Comment
$x is undefined, i guess this code is for php
<a href="#" onclick="slideDown('<?=$x?>');" class="info">i</a>
onclickon the markup when you're using jQuery? Seems contradictory...slideDownis defined only within your jQueryready()callback.ready()jQuery function just use$(".info").click(slideDown)