Return to Snippet

Revision: 28763
at July 14, 2010 03:12 by iqwebdev


Initial Code
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 );
       }
});

<div class="news">First news</div>
<div class="news">Second news</div>
<div class="news">Third news</div>
<a class="archive" href="#"></a>

Initial URL

                                

Initial Description

                                

Initial Title
Display Only First X Divs, Toggle Rest

Initial Tags

                                

Initial Language
jQuery