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 1028777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:26:38+00:00 2026-05-16T12:26:38+00:00

We have list in html: <ul class=list> <li>some text<li> <li>some text<li> <li>some text<li> <li>some

  • 0

We have list in html:

<ul class="list">
<li>some text<li>
<li>some text<li>
<li>some text<li>
<li>some text<li>
<li>some text<li>
...
<li>some text<li>
</ul>

There can be more than 100 <li>

How to do:

1) Add for each <li> id with number, like:

<li id="item1">some text<li>
<li id="item2">some text<li>
...
<li id="item200">some text<li>

and so on, to the end.

2) Count all <li> inside <ul class="list">

3) After second step, if there are more than 60 <li>, add their IDs (item number) to array 1, all other’s <li> IDs add to array 2 (from 60 to the end, from 60 to 500 if there are 500 <li>).

Thanks!

  • 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-16T12:26:39+00:00Added an answer on May 16, 2026 at 12:26 pm

    Step 1:

    var $li = $('ul.list > li').attr('id', function(i) { return "item" + (i + 1) });
    

    Step 2:

    var count = $li.length;
    

    Step 3:

    if(count > 60) {
        var arr1 = $li.slice(0,60);
        var arr2 = $li.slice(60);
    }
    

    EDIT: Mis-spelled function. Fixed.

    Note: Of course, you don’t need a count variable. $li.length can go inside the if() statement.

    Note: The .slice() method will return a jQuery object. If you actually want an array, add .get() after .slice(). Or with jQuery 1.4 or later, you can use .toArray().

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

Sidebar

Related Questions

If I have List<String> text how can I create a sub-list of all continious
I have a list of more than 15 thousand latitude and longitude coordinates. Given
I have a list of integers, List<Integer> and I'd like to convert all the
I have a list of 2-item tuples and I'd like to convert them to
I have a List<int> and a List<customObject> . The customObject class has an ID
I have a list, each item of which has several things in it, including
I have an List and I'd like to wrap it into an IQueryable. Is
OK, I have a list ( <ul> ) then inside each <li> element I
I have this href link with text either attivo or non attivo User can
I have following problem. In my view model I defined some list properties as

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.