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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:49:58+00:00 2026-06-02T12:49:58+00:00

I have two div’s, one above the other and both have a table inside

  • 0

I have two div’s, one above the other and both have a table inside them with the same amount of columns. I want the columns to be the same width size in both and aligned. If a columns in on div expands, i want the column parallel in the other div to expand to the same with.

NB: The Columns have no width.
Link to the HTML code below:


HTML:

<div id="A">
   <table>
       <tbody>
           <tr>
               <th></th>
               <th>Blah! Blah</th>
               <th>adsdsdadasdasdasdasd</th>
           </tr>
       </tbody>
   </table>
</div>
<br/>
<div id="B">
   <table>
       <tr>
          <th>left head</th>
          <td class="col1"></td>
          <td class="col2">Hello World!</td>
       </tr>
       <tr>
          <th>left head</th>
          <td class="col1">Hello World!</td>
          <td class="col2">dsfsdfgdsgdsgdsfgdsgdsgfdfgdf</td>
       </tr>       
   </table>
</div> 

JQuery:

$(document).ready(function() {
    $('#updatetopdiv').click(function(){        
            //Properly align parallel div's top to bottom 
            var tbl1 = $("#A table tr td");
            var tbl2 = $("#B table tr td");
            tbl1.each(function(i) {
                if (tbl2.eq(i).width() < $(this).width()) {
                    tbl2.eq(i).width($(this).width());
                } else {
                    $(this).width(tbl2.eq(i).width());
                }
            });
     });
});​

​

  • 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-02T12:50:07+00:00Added an answer on June 2, 2026 at 12:50 pm
    ​$(document).ready(function(){
       var tbl1 = $("#A table tr td");
       var tbl2 = $("#B table tr td");
        tbl1.each(function(i){
            if (tbl2.eq(i).width() < $(this).width()){            
               tbl2.eq(i).width($(this).width());
            } else {
               $(this).width(tbl2.eq(i).width()); 
            }    
        });
    });​
    

    This works, though it doesn’t run until load.

    Also placed here: http://jsfiddle.net/gwUFb/3/

    EDIT:

    I know you said you already got it working, but here’s my original code, edited for your use case:

    $(document).ready(function(){
       var tbl1 = $("#A table tr th");
       var tbl2 = $("#B table tr td,#B table tr th");
        tbl1.each(function(i){
            if (tbl2.eq(i).width() < $(this).width()){            
               tbl2.eq(i).width($(this).width());
            } else {
               $(this).width(tbl2.eq(i).width()); 
            }    
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two ULs, one above the other: <ul id=one> <li> <li> <ul> <div
I have two div's and I want to show them next to each other.
I have two HTML elements inside a div. I want to display them in
I have two div's one has textbox in it and other just plain text.
I have one parent DIV inside parent DIV i have two DIV one in
I have two div's (side by side) inside a parent div, i want right
I have two inner divs which are nested inside a wrapper div. I want
I have two divs both containing images. Here is some example code: <div id=one>
I have two div's on a page: one floating left and the other right:
I want to have two div's side-by-side with the left one fixed and the

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.