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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:15:58+00:00 2026-06-19T01:15:58+00:00

I couldn’t think of a more descriptive title, so I do hope it makes

  • 0

I couldn’t think of a more descriptive title, so I do hope it makes sense (feel free to correct me if I am wrong).

Basically I am adding tables to a site and the columns will automatically resize according to the amount of columns being added.
Adding a single works perfectly well, where it’s getting a bit complicated for me (perhaps over the head) is as soon as I add an additional table on the same page – the script which runs counts all of the columns in their entirety.
For instance, if I add a three column table at the top of the page then and additional three column table at the bottom – the script then counts a total of 6 columns then divides 100 by that number..

Is there a simple way to create a variable or a table count so that the script at the bottom detects separate tables and resizes the columns per table?

Snippets of the code below:

<div class="table<?php echo $tblid; ?>">
        <div class="cols">
        </div>

    ..code going on here..
        <div class="cols">
        </div> 
    ..Some more code going on here..
</div>

    var v = jQuery('.table .cols').length;

    var cw = (100/v);

    jQuery('.table .cols').css('width',cw+'%');

  • 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-06-19T01:15:59+00:00Added an answer on June 19, 2026 at 1:15 am

    If i am not wrong, youu have two tables with the same classname , so your selector jQuery('.table .cols') gets both the table and jQuery('.table .cols').length; will give you the length of the cols combining both the tables…

    what you can do is.
    Give them seperate class and call each one..

    HTML

     <div class="table1">
        <div class="cols">
        </div>
    
      ..other code going on here..
    
    </div>
    
    <div class="table2">
        <div class="cols">
        </div>
    
      ..other code going on here..
    
    </div>
    

    Jquery

    jQuery(function(){
      jQuery('div[class^="table"]').each(function(){
        var obj=jQuery(this).find('.cols');
        var v = obj.length;
        var cw = (100/v);
    
        obj.css('width',cw+'%');
      });
    });
    

    this should work for any number of tables..

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

Sidebar

Related Questions

Couldn't seem to think of a good title, my apologies. Feel free to change
(couldn't think of a better title, feel free to edit it to a title
Couldn't remember better title, feel free to change it to something better :) My
Couldn't think of a more appropriate question title, but I'm looking for some advice
I couldn't think of a way to word the title, so sorry for that,
couldn't think of a better title. I just want someone to let me know
I couldn't be more specific in the title part but I want to do
(Couldn't think of any simpler way to write the title for this, but the
(couldn't think of a better title, sorry) So I've got my layout page, on
I couldn't think of a better title name, but to the point. I wanted

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.