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:
- ...
- <ul>
- <li><a href="#" id="page1link">Page 1</a></li>
- <li><a href="#" id="page2link">Page 2</a></li>
- <li><a href="#" id="page3link">Page 3</a></li>
- </ul>
- ...
- <div id="page1">Content Page 1</div>
- <div id="page2">Content Page 2</div>
- <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:
- $(document).ready(function(){
- $('a.menulink').click(changepage($this));
- });
- var activePage = 'page1'; //Setting inital start page as active
- function changepage(newPage) {
- $(activePage).animate(...);
- $(newPage).animate(...);
- activePage = newPage; // Set parameter for active page
- }
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