Reputation: 185
I am trying to do a content slider controlled with a menu. Div elements will be placed in a wrapper and I am changing its position using script. Please check below code
jQuery(document).ready(function() {
function goto(id){
jQuery(".contentbox-wrapper").animate({"left": -(jQuery(id).position().left)}, 600);
}
});
and html where the function calling is,
<li><a href="#" onClick="goto('#homePage', this); return false">Home</a></li>
<li><a href="#" onClick="goto('#aboutPage', this); return false">About</a></li>
and the content divs is like
<div class="contentbox-wrapper">
<div id="homePage" class="contentBox">
content here
</div>
<div id="aboutPage" class="contentBox">
content here
</div>
</div>
the problem is, when i click on the menu items i am getting this error
" Uncaught ReferenceError: goto is not defined "
Please help..
Upvotes: 1
Views: 474
Reputation: 670
You're passing goto two parameters when you reference it in the onclick attributes of the links but in its definition it only accepts a single param, the id.
Upvotes: 0
Reputation: 5008
You should put the goto function outside the document ready event handler function. Also your function is taking a single parameter but you're using two every time you call it (not the case, just doesn't make much sense).
Upvotes: 1