Code Snippet
Display Only First X Divs, Toggle Rest
var news = 2;
hidenews = "- Hide news archive";
shownews = "+ Show news archive";
$(".archive").html( shownews );
$(".news:not(:lt("+news+"))").hide();
$(".archive").click(function (e) {
e.preventDefault();
if ($(".news:eq("+news+")").is(":hidden")) {
$(".news:hidden").show();
$(".archive").html( hidenews );
} else {
$(".news:not(:lt("+news+"))").hide();
$(".archive").html( shownews );
}
});
HTML:
<div class="news">First news</div>
<div class="news">Second news</div>
<div class="news">Third news</div>
<a class="archive" href="#"></a>
Reference URL
sweet, thank you!
Excellent, thanks for this =)
Sorry, the reference URL has not been available for a long time. It’s fixed now!
I had to change the referene URL, sorry… now it’s available @ http://czentnar.trioartmusic.hu/examples/displayfirst.html
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.