I have created a little example,please have a look,
http://jsfiddle.net/bWTwL/
I want to have a panel like this so that:
1.li(home).click > slide panel left >content fadeIn
2.X(click) > content fadeOut > slide panel right
Now,I have 7 list items like home,about me etc.I want that when user clicks on any list item,the particular content for that list item (home,about me etc) should fadeIn.
and if the panel is already visible then only content should fadeIn/Out on click.
I thought to write each function for each of them but that would be a very long messy code.
I thought something like html5 data-attribute to do the job but failed.Please see the same effect here to have a better understanding: http://www.unpezvivo.com/proyectos/themeforest/cspp/02/#
Thanks in advance.
Something along these lines will work fine.
1. CSS
2. Markup
3. jQuery
I have used the pub/sub pattern, which makes things easier. We minimize the redundant code. And the work flow is easier to follow.
I would strongly suggest that you use namespaces for custom events (e.g
togglePanel,hidePanel,showPanel, …).I didn’t do that in this code, because it is already complicated for novice scripters, and it is left to you as a homework to take this code further on.