Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7760795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:59:03+00:00 2026-06-01T13:59:03+00:00

I have created a little example,please have a look, http://jsfiddle.net/bWTwL/ I want to have

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:59:04+00:00Added an answer on June 1, 2026 at 1:59 pm

    Something along these lines will work fine.

    1. CSS

    div.panel {
        display:none;
        position: absolute;
        top: 0;
        width:70%;
        right:0%;
        height: 100%;
        z-index: 3;
        margin: 0;
        overflow:hidden;
        background-color:black;
    }
    .panel div.content {
        display:none;
        font-family:arial;
        color:white;
        padding:50px;
        overflow:hidden;
    }
    span.close {
        position:absolute;
        right:10px;
        top:15px;
        cursor:pointer;
    }​
    

    2. Markup

    <ul id="menu">
        <li><a id="home" href="#">Home</a></li>
        <li><a id="about-me" href="#">About Me</a></li>
    </ul>
    
    <div class="panels">
        <div class="panel home">
            <div class="content">
                <span class="close">X</span>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis id ligula elit, vitae tincidunt massa. Vestibulum quis tempus lectus. Vestibulum diam dolor, tristique eget tincidunt eu, posuere nec nulla. Nulla a sollicitudin diam. Nunc venenatis dui in turpis ultricies semper. Nulla justo nibh, volutpat nec rutrum id, viverra ac nulla. Maecenas elit felis, rhoncus sit amet imperdiet eget, ultricies ut lorem. Praesent sed felis diam</p>
            </div>
        </div>
        <div class="panel about-me">
            <div class="content">
                <span class="close">X</span>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis id ligula elit, vitae tincidunt massa. Vestibulum quis tempus lectus. Vestibulum diam dolor, tristique eget tincidunt eu, posuere nec nulla. Nulla a sollicitudin diam. Nunc venenatis dui in turpis ultricies semper. Nulla justo nibh, volutpat nec rutrum id, viverra ac nulla. Maecenas elit felis, rhoncus sit amet imperdiet eget, ultricies ut lorem. Praesent sed felis diam</p>
            </div>
        </div>
    </div>
    

    3. jQuery

    $(document).ready(function() {
        var $panels = $('.panels > .panel');
        $('#menu > li').on('click', 'a', function() {
            $panels.filter('.'+this.id).trigger('togglePanel');
        });
        $panels
            .on('togglePanel', function(){
                var $this           =   $(this)
                  , $activePanels   =   $panels.filter(':visible').not($this);
                if ($activePanels.length) {
                    $activePanels
                        .one('panelHidden', function(){
                            $this.is(':visible')
                            ? $this.trigger('hidePanel')
                            : $this.trigger('showPanel');
                        })
                        .trigger('hidePanel');
                } else {
                    $this.is(':visible')
                    ? $this.trigger('hidePanel')
                    : $this.trigger('showPanel');
                }
            })
            .on('hidePanel', function(){
                var $this = $(this);
                $this.find('.content').fadeOut(500, function() {
                    $this.animate({
                        'width': 'hide'
                    }, 1000, function(){
                        $this.trigger('panelHidden');
                    });
                });
            })
            .on('showPanel', function(){
                var $this = $(this);
                $this.animate({
                    'width': 'show'
                }, 1000, function() {
                    $this.find('.content').fadeIn(500, function(){
                        $this.trigger('panelShown');
                    });
                });
            });
        $panels.find('.content .close').on('click', function() {
            $(this).closest('.panel').trigger('togglePanel');
        });
    });​
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a little example(below) on my attempt to safely stop multiple threads
Please excuse the simplicity and length of this, but I have a little test
I have created a little test project to try to resolve a problem I
Hi I have created a little application to move some files around and put
Ok, I have created a little utility with AppleScript and used Automator to turn
I am a little stuck. I have created almost everything in the picture below.
I have a page which contains a jQuery-UI horizontal slider, created using a little
I'm a jQuery newbie, and I have trouble with a little script I created.
I have written a little console application that uses s#arp. I can create an
I have created a Virtual Desktop Manager for a client that allows him to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.