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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:12:16+00:00 2026-05-18T02:12:16+00:00

I have a function that gets raw HTML to output to a table, but

  • 0

I have a function that gets raw HTML to output to a table, but I want to take out the first three columns and put them in another div.

I am considering making a div on the page that is hidden, setting this div’s html to the raw HTML I get, and then using the selector syntax to strip it into each table’s div. Is there a way to do this without the intermediate faux-div to hold the raw HTML?

  • 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-18T02:12:17+00:00Added an answer on May 18, 2026 at 2:12 am

    I’m not sure exactly why you’d want to do this, rather than arrange your data server-side, but one approach that works is:

    $(document).ready(
        function(){
            $('table').click(
                function(){
                    $('<table />').appendTo('#newTable').addClass('new');
                    $('table').eq(0).find('tr td:first-child').each(
                        function(){
                            $(this).appendTo('.new').wrap('<tr></tr>');
                        });
                });
        });
    

    With the (x)html:

    <table>
        <tr>
            <td>1:1</td>
            <td>1:2</td>
            <td>1:3</td>
        </tr>
        <tr>
            <td>2:1</td>
            <td>2:2</td>
            <td>2:3</td>
        </tr>
        <tr>
            <td>3:1</td>
            <td>3:2</td>
            <td>3:3</td>
        </tr>
        <tr>
            <td>4:1</td>
            <td>4:2</td>
            <td>4:3</td>
        </tr>
    </table>
    <div id="newTable"></div>
    

    JS Fiddle demo

    The demo uses jQuery’s click() event, but that’s just to show it working interactively; it could certainly be placed straight into the DOM-ready/$(document).ready(function(){/* ... */}); event.


    The above code would allow repeated clicks (each time moving the first ‘column’ into a new table), the edit removes that possibility using jQuery’s one(), giving the following jQuery:

    $(document).ready(
        function(){
            $('table').one('click',
                function(){
                    $('<table />').appendTo('#newTable').addClass('new');
                    $('table').eq(0).find('tr td:first-child').each(
                        function(){
                            $(this).appendTo('.new').wrap('<tr></tr>');
                        });
                });
        });
    

    JS Fiddle demo, featuring one().

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

Sidebar

Related Questions

I have a function that gets a string passed to it. When testing the
I have an ASP.NET MVC web app and have a function that I need
I would like to write a Perl function that gets a GFF3 filename and
hallo all. i am trieng to build a function that gets all ul's on
I'm looking for a way to get a HTML element from a string that
I have a textbox that is wired up using jQuery UI 1.8.4 autocomplete. I
I am using an open source library to connect to my webserver. I was
According to Facebook graph API we can request a user profile picture with this
I am parsing a text (css) file using fscanf. The basic goal is simple;
Am I doing something wrong? Or is there a better way to do this?

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.