I am trying to create an accordion function similar to a blog, where you first see a set of lines (more precisely, 100px), and when you click on the blog title, the blog post expands to full height.
This is what I still have:
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 are doing (as far as I understand, I am completely new when it comes to jQuery!):
We store some information in our variables and then define a function that will extend the .list-item to the actual height .list-item-right, and when we click it again, it will go back to its “closed” height of 100 pixels.
Now, what I want to do is not have a .toggle event or a .click event if you click .list-item.
, , .expand .list-item-left h2 ( ).
- , , , .
,
K.