Call to separate function and forwarding parameters

Call to separate function and forwarding parameters

Hello there,

I'm new to JQuery and experiencing a problem, that I couldn't find an answer to in the forums. Actually I don't know what to search for exactly...

Anyways:

I got a Menu and several Divs:
  1. ...
  2. <ul>
  3.   <li><a href="#" id="page1link">Page 1</a></li>
  4.   <li><a href="#" id="page2link">Page 2</a></li>

  5.   <li><a href="#" id="page3link">Page 3</a></li>
  6. </ul>
  7. ...
  8. <div id="page1">Content Page 1</div>
  9. <div id="page2">Content Page 2</div>
  10. <div id="page3">Content Page 3</div>
No I want to set up a "universal" JQuery function that animates the fade-out of the old and the fade-in of the new div:
  1. $(document).ready(function(){
  2.     $('a.menulink').click(changepage($this));
  3. });
  4. var activePage = 'page1'; //Setting inital start page as active
  5. function changepage(newPage) {
  6.       $(activePage).animate(...);
  7.       $(newPage).animate(...);
  8.       activePage = newPage; // Set parameter for active page
  9. }
The problem is, of course, that I have no clue, what the parameter  to hand to the function changepage($this) should look like.

Any ideas or links to similar problems?

Thank you,

Tim