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 7866861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:32:03+00:00 2026-06-03T00:32:03+00:00

I’m trying to create an accordion like blog function, where at first you see

  • 0

I’m trying to create an accordion like blog function, where at first you see a set of rows (100px to be precise), and when you click the blog header the blog post expands to its full height.

This is what I have so far:

HTML:

                    <ul class="blog">

                        <li class="list-item">
                            <div class="list-item-left">
                                <h2 class="expand">Project Eden</h2>

                                <time>07.08.2012</time>
                            </div>
                            <div class="list-item-right">
                                <p>"Sed ut perspiciatis unde </p>                                   
                            </div>
                            <div class="list-item-whitespace"></div>
                        </li>

                        <li class="list-item">
                            <div class="list-item-left">
                                <h2>Project Eden</h2>

                                <time>07.08.2012</time>
                            </div>
                            <div class="list-item-right">
                                <p>"Sed ut perspiciatis unde</p>
                            </div>
                            <div class="list-item-whitespace"></div>
                        </li>

</ul>

jQuery:

var $listItems = $('.list-item');
var closedHeight = 100;
var slideSpeed = 1000;

$(".list-item").click(function() {
  if($(".list-item:animated").length) 
    return false;
}).toggle(function() { 
        var openHeight = $(this).parents("div:first").find(".list-item-right").height();
    $(this).animate({height:openHeight}, slideSpeed,"easeOutExpo");
    $(this).children('.list-item-whitespace').css({'display':'none'});
}, function(){
        $(this).animate({height:100}, slideSpeed,"easeOutExpo");
        $(this).children('.list-item-whitespace').css({'display':'block'});  
});

So basically what we’re doing (to my understanding, I’m quite the newbie when it comes to jQuery!):

We’re storing some information in our variables, and then we define a function which will expand the .list-item to the actual height of .list-item-right , and when we click it again it will revert back to its “closed” height of 100px.

Now, what I want to do is to not have the .toggle event, or .click event fire off when clicking .list-item.

Instead, I want it to fire off ONLY when you click the .expand class, or .list-item-left h2 (if you will).

If this makes any sense to anyone, please do tell me where I’m at a loss.

Best regards,
K.

  • 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-03T00:32:05+00:00Added an answer on June 3, 2026 at 12:32 am

    This is how I would do it. It requires restructuring your html a bit. You enclose the list item contents in a parent div. You use this to find out what the non-overflowed height is.

    When you expand a list item you add an open or closed class so that you know the state.

    I also got rid of what I imagine was a clearing div and gave the container div overflow: auto which causes the contained elements to self clear.

    http://jsfiddle.net/WZVb6/1/

    //set all blog posts to 100px to start
    $('li.list-item h2').click(function() {
        $this = $(this);
        var nheight = $this.closest('.naturalheight').height();
    
        if ($this.hasClass('open')) {
            $this.closest('li').animate({
                height: 100
            });
            $this.removeClass('open');
        }
        else {
            $this.closest('li').animate({
                height: nheight
            });
            $this.addClass('open');
        }
    
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
I am trying to render a haml file in a javascript response like so:
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words

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.