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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:57:42+00:00 2026-06-19T00:57:42+00:00

I have a table and I am trying to create something like this on

  • 0

I have a table and I am trying to create something like this on the basis of value existence in table cell.

Result to be obtained – jsFiddle Result

<table width="100%" border="1" cellspacing="0" cellpadding="0" class="top-table-bg" id="mytable">
                        <tbody><tr>
                            <th style="width:200px"><br>First Row<br>Second Row<br>Third Row<br>Forth Row<br></th>
                            <th style="width:200px"><p>Heading1<br>
                            </p>
                              <p>First Row<br>
                              </p></th>
                            <th style="width:200px"><p>Heading2
                              <br>
                          </p>
                              <p>Second Row
                                <br>
                          Forth Row<br>
                              </p></th>
                            <th style="width:200px"><p>Heading3
                              <br>
                          </p>
                              <p>Second Row<br>
                          Third Row<br>
                          <br>
                              </p></th>                         
                        </tr>
                        <tr>
                            <td style="width:200px;text-align:center;">First Row</td>
                            <td style="width:200px;text-align:center;">20</td>
                            <td style="width:200px;text-align:center;"></td>
                            <td style="width:200px;text-align:center;"></td>
                        </tr>
                        <tr>
                            <td style="width:200px;text-align:center;">Second Row</td>
                            <td style="width:200px;text-align:center;"></td>
                            <td style="width:200px;text-align:center;">20</td>
                            <td style="width:200px;text-align:center;">20</td>
                        </tr>
                        <tr>
                            <td style="width:200px;text-align:center;">Third Row</td>
                            <td style="width:200px;text-align:center;"></td>
                            <td style="width:200px;text-align:center;"></td>
                            <td style="width:200px;text-align:center;">20</td>
                        </tr>   
                        <tr>
                            <td style="width:200px;text-align:center;">Forth Row</td>
                            <td style="width:200px;text-align:center;"></td>
                            <td style="width:200px;text-align:center;">20</td>
                            <td style="width:200px;text-align:center;"></td>
                        </tr>       
                    </tbody></table>

And this is what I tried, but it populates with all values 🙁

My try – jsFiddle Try

$('#mytable>tbody>tr').each( function(){
   if($(this).text() != '' ) {
   $('th').append($(this).children('td').first().text() + "<br>");
   }
});

let me know what I am doing wrong..Starter in jquery..so excuse if a basic one

  • 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-19T00:57:44+00:00Added an answer on June 19, 2026 at 12:57 am
    $('#mytable > tbody > tr').each(function() {
      var $tr = $(this);
    
      $tr.children("td").not(":nth-child(1)").each(function() {
        if ($(this).text() != '') {
          var index = $(this).index() + 1;
    
          $("th")
            .filter(":nth-child(" + index + ")")
            .append("<br/>" + $tr.children("td:first").text());
        }
      });
    })
    #mytable th {
      width:200px;
    }
    
    #mytable td {
      text-align: center;
      width: 200px;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <table width="100%" border="1" cellspacing="0" cellpadding="0" class="top-table-bg" id="mytable">
      <tr>
        <th></th>
        <th>Heading1</th>
        <th>Heading2</th>
        <th>Heading3</th>
      </tr>
      <tr>
        <td>First Row</td>
        <td>20</td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td>Second Row</td>
        <td></td>
        <td>20</td>
        <td>20</td>
      </tr>
      <tr>
        <td>Third Row</td>
        <td></td>
        <td></td>
        <td>20</td>
      </tr>
      <tr>
        <td>Forth Row</td>
        <td></td>
        <td>20</td>
        <td></td>
      </tr>
    </table>

    I’ve also replaced the inline style declarations, with an external CSS.

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

Sidebar

Related Questions

This is what I'm trying to do: I have 2 tables... CREATE TABLE `parent`
I am trying to have a table like this: Manager Expert Adminis. Staff Dept
In MSSQL 2008 I have table and data which looks like this create table
Hi i'm trying to create a league table in which i have several different
I have a data.frame and I'm trying to create a frequency table that shows
I am trying to create something similar to the nhibernate fluent syntax. I have
I have this table in my Android SQLite DB: CREATE TABLE statistics (subject TEXT,
Say I have a table like so: CREATE TABLE big_table (UUID varchar(32) not null,
I have a data model something like this: # columns include collection_item_id, collection_id, item_id,
I'm trying to follow http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/ And have created a very simple example http://jsfiddle.net/6wbZQ/ It's

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.