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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:37:23+00:00 2026-05-24T16:37:23+00:00

As the IE family doesn’t accept CSS3 column properties, I’m trying to split a

  • 0

As the IE family doesn’t accept CSS3 column properties, I’m trying to split a list of li into 5 columns with javascript/jquery. In the process, I was told that looping an array backward is faster than looping it normally. I’ve tried it but it gives me a funny results. The last column is appearing as the 1st column, which I don’t want. I don’t know what’s wrong with the code. On top, the code reads slow in browser… Please give me some light.

JS/jQuery:

var JL = {}, JL.Module = {};

JL.Module.indexSort = function(){
  var indexContainers = $('.index-section'),
      indexControls = $('ul.index-navigation li'),
      ieIndexContainers = $('.ie6, .ie7, .ie8, .ie9').find('.index-section'),
      ulWrap = '<ul class="new-col" />',
      colCount = 5,
      subLi;

  indexContainers.hide().filter(':first').show();

  indexControls.filter(':first').addClass('selected');

  //IE family don't accept css columns properties, so have to use JS
  ieIndexContainers.each(function () {  
     var thisElem = $(this),
         indexUl = thisElem.find('ul'),
         indexLi = thisElem.find('li'),
         indexLiLen = indexLi.length,
         liPerCol = Math.ceil(indexLiLen / colCount),
         lastColCount = indexLiLen % liPerCol,
         sliceStart = indexLiLen - lastColCount,
         sliceEnd = indexLiLen,
         subLi,
         i;

     ieIndexContainers.find('ul').addClass('new-col');

     setTimeout(function(){
        sliceEnd = 0;
        sliceStart = -1;

        // Looping the array backwards
        for(i = colCount - 1; i > 0; i--){
            sliceEnd = sliceStart;
            sliceStart = (sliceEnd - liPerCol >= 0) ? sliceEnd - liPerCol : 0;
            subLi = indexLi.slice(sliceStart, sliceEnd);
            indexUl.after($(ulWrap).append(subLi));

        }

        ieIndexContainers.find('.new-col').show();

      }, 0);

  });
}

HTML:

<div id="s" class="index-section">
  <h2>s</h2>
  <ul>
    <li><a href="#">Lorem ipsum</a></li>
    <li><a href="#">Aorem</a></li>
    <li><a href="#">Apsum</a></li>
    <li><a href="#">Aonor</a></li>

    <li><a href="#">Lorem ipsum</a></li>
    <li><a href="#">Asdijnd oasd</a></li>
    <li><a href="#">Awrom</a></li>
    <li><a href="#">Aoidn iojd</a></li>

    <li><a href="#">Lorem ipsum</a></li>
    <li><a href="#">Asddewdwe</a></li>  
    <li><a href="#">Apsum</a></li>
    <li><a href="#">Aonor</a></li>

    <li><a href="#">Lorem ipsum</a></li>
    <li><a href="#">Asdijnd oasd</a></li>
    <li><a href="#">Awrom</a></li>
    <li><a href="#">Aoidn iojd</a></li>

    <li><a href="#">Lorem ipsum</a></li>
    <li><a href="#">Asddewdwe</a></li>          
  </ul>
</div>
  • 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-24T16:37:25+00:00Added an answer on May 24, 2026 at 4:37 pm

    Just loop it forward. The being slower relates to not caching the array’s length. However, you do cache the upper bound of the for-loop in colCount. Don’t worry about performance, just do the loop the right way around. Let it count forward.

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

Sidebar

Related Questions

I've rewritten my family web site using JavaScript (JQuery) making Ajax calls to PHP
Friends/family/etc ask me what I do and it always causes me pause while I
Which family should I start to learn? (Never did any programming on microcontroller)
My code: body { font-family:Verdana,Arial,Helvetica,sans-serif; } .myfont { font-family:Verdana,Arial,Helvetica,sans-serif; } <body> Hello <select> <option>
Using any member of the Windows Server family, I can set up an active
I am tasked with updating a family of web sites that promote scientific conferences
I'm implementing unit tests for a family of functions that all share a number
I have a project the requires the use of the exec family. My project
I keep stumbling on the format specifiers for the printf() family of functions. What
Every Christmas we draw names for gift exchanges in my family. This usually involves

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.