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

I have an ordered list in HTML. I would like to add styling only
I have a knockout template like this: <script type=text/html id=list> <ul data-bind=foreach: items> <li
I have a list of html pages which may contain certain encoded characters. Some
I have multiple dropdown list: @Html.DropDownListFor(x => x.HaveColoSpace.SelectedOptions, new SelectList(Model.HaveColoSpace.Options, Value, Text), new {
I have a bulleted list using HTML and I would like the words to
If you have a standard ordered list in HTML like: <ol> <li>First</li> <li>Second</li> <ol>
I have defined a drop down list in html as follows. I have appended
I have created a populated dropdown list in HTML. When the two dropdowns have
I have a list of mysql timestamps. I want to produce an html menu,
In our HTML page, we have a list of tags to load in many

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.