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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:11:37+00:00 2026-05-28T19:11:37+00:00

I have a table that currently has two columns per row and I need

  • 0

I have a table that currently has two columns per row and I need to split it using jQuery.

I tried this:

$(document).ready(function() {
    $('.TextBold').after('</tr><tr>');
});

…but it doesn’t work. I wonder if can add a <p>Test</p> instead of </tr><tr> there?

Here you can see my code in JSFiddle .. http://jsfiddle.net/QjJhU/

I will appreciate if someone can explain the issue.

  • 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-28T19:11:38+00:00Added an answer on May 28, 2026 at 7:11 pm

    The problem is that you are imagining that jQuery (and Javascript in general) edits the HTML document. It doesn’t. The browser reads the HTML, then creates a DOM structure from it. At that point, the HTML content is utterly irrelevant. The only thing the browser cares about is the DOM structure.

    This means that you can’t add bits of elements: you can only add whole elements (or text nodes) to a document. You’re trying to close one tag (with </tr>) then open another one (with <tr>). In fact, the browser reads </tr><tr> and makes a DocumentFragment out of it. Since the closing tag is invalid on its own, it is removed. Then the <tr> is turned into an entire element in its own right: effectively, <tr></tr>. This is valid HTML, so it is turned into the valid DOM element and that is inserted.

    You need to work out a way of removing the td from one tr, creating a new tr and adding the td to it.

    Something like this should work:

    $('.TextBold').each(function() {
        $('<tr/>').insertAfter(this.parentNode).append($(this).next());
    });
    

    This says:

    • for each TextBold element, do the following:
      • create a new tr element
      • insert it after the TextBold‘s parent element (which is the tr)
      • append the element that follows the TextBold to the new tr (this also has the effect of removing it from its current position)

    Here’s a jsFiddle with this working code.

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

Sidebar

Related Questions

OK I have a table that has two columns, userID and courseID. It is
I have a table that consists of two columns: question and answer. I currently
I have a table that has an AUTO_INCREMENT field. Currently, it is also a
I currently have a table structure that looks something like this(some details omitted): ColumnName
Background I have a GridView that builds a table using an ObjectDataSource . This
I'm currently working with MS SQL 2005, and have a table that has 17
Currently we have a table that we use to track inivitations. We have an
Currently I have a table that I search upon 4 fields, FirstName, LastName, MiddleName,
I'm trying to normalize a mysql database.... I currently have a table that contains
Greetings, I have some mysql tables that are currently using an md5 hash as

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.