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

  • Home
  • SEARCH
  • 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 3244338
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:32:21+00:00 2026-05-17T18:32:21+00:00

I have a dynamic page which has a parent div called ‘divWiz’ where I

  • 0

I have a dynamic page which has a parent div called ‘divWiz’ where I have to do the following:

  • count total div’s inside ‘divWiz’ and hide 50% of them. For example: If I have 50 child div’s inside divwiz, I want to show 25 and hide the rest.

  • At the end of the 25 div’s, two links should appear that says ‘Show Next’ and ‘Show All’.

If the user clicks the ‘Show Next’ link, the first 25 should be hidden and the next 25 visible. ‘Show Next’ link should be invisible now.

If the user clicks ‘Show All’, all the div’s should be visible. Both the links will disappear once the user clicks Show All.

How can I do this? Since this involves lot of traversing, I am looking for jquery code with performance.

  • 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-05-17T18:32:21+00:00Added an answer on May 17, 2026 at 6:32 pm

    You can make use of the index numbers:

    $('#divWiz > div:lt(25)')          // all divs of index 0 to 24
    
    $('#divWiz > div:lt(50):gt(24)')  // all divs of index 25 to 49
    

    Caution! :gt(-1) doesn’t work!

    So, here’s a quick and dirty full working example of something like what you’re describing:

    HTML:

    <input value=" Next " type="button"/>
    <input value=" Prev " type="button"/>
    <input value=" Show All " type="button"/>
    <div id="divWiz"></div>
    

    JS:

    $(function() {
        var i, cutoff, total = 50;
        for(i=0; i<total; ++i)
            $(document.createElement("div")).html(i).appendTo("#divWiz");
    
        cutoff = total/2;
    
        $("#divWiz > div").hide();
        $("#divWiz > div:lt("+cutoff+")").show();
    
        $("input[value=' Next ']").click(function() {       
            $("#divWiz > div").hide();        
            $("#divWiz > div:gt("+(cutoff - 1)+")").show();
        });
    
        $("input[value=' Prev ']").click(function() {       
            $("#divWiz > div").hide();        
            $("#divWiz > div:lt("+cutoff+")").show();    });    
    
        $("input[value=' Show All ']").click(function() {       
            $("#divWiz > div").show();        
        });        
    });
    

    Try it out with this jsFiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Embedded custom-tag in dynamic content (nested tag) not rendering. I have a page that
We're looking at doing a MOSS 2007 site which will have a fairly dynamic
I have a custom built ajax [div] based dynamic dropdown. I have an [input]
I have a dynamic query that returns around 590,000 records. It runs successfully the
I have a Dynamic Data Entities Web Application that uses a database with GUIDs
I have a dynamic class that serves as a storage container for configuration settings.
How can I have a dynamic variable setting the amount of rows to return
When C# 4.0 comes out and we have the dynamic keyword as described in
(Eclipse 3.4, Ganymede) I have an existing Dynamic Web Application project in Eclipse. When
I have recently written a dynamic querying tool using expression trees and as I

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.