Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Jquery expand Re: Jquery expand

#120889
Mottie
Member

@wragen22 Ah, ok. I did miss the `hide()` at the beginning, so that’s why the toggle was off. I changed it to `slideDown` and `slideUp` to make it more concise. I also ended up changing around the css a tiny bit. The number was there, it was just white. And the buy button span was the same color as the background. Anyway, [try it now](http://codepen.io/Mottie/pen/BLzpf)!

$(function(){

$(‘.grid p, .grid .right-module’).hide();
$(‘.grid h1’).addClass(‘pointer’).click(function() {
var $article = $(this).closest(“.grid”),
$siblings = $article.find(“p,.right-module”)
if (!$article.hasClass(‘expanded’)) {
$siblings.slideDown(‘slow’, function() {
$article.addClass(‘expanded’);
});
} else {
$article.removeClass(‘expanded’);
$siblings.slideUp(‘slow’);
}
});

});