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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:27:54+00:00 2026-05-19T09:27:54+00:00

I am really confused with the behavior. Any help will be appreciated on this.

  • 0

I am really confused with the behavior. Any help will be appreciated on this. I have a simple table and it is behaving differently though using the same JQuery call.

<table class="PrintTable">
    <tr>
      <td>
        <table>
            <thead>
                <tr><th>Type Of Transaction</th></tr>
            </thead>
            <tbody>
                <tr>
                    <td>Name</td>
                </tr>
                <tr>
                    <td>Age</td>
                </tr>
            </tbody>
        </table>
      </td>
      <td>
        <table>
            <thead>
                <tr><th>2006</th></tr>
            </thead>
            <tbody>
                <tr>
                    <td>Andi</td>
                </tr>
                <tr>
                    <td>25</td>
                </tr>
            </tbody>
        </table>
      </td>
      <td>
        <table>
            <thead>
                <tr><th>2007</th></tr>
            </thead>
            <tbody>
                <tr>
                    <td>tom</td>
                </tr>
                <tr>
                    <td>26</td>
                </tr>
            </tbody>
        </table>
      </td>
     </tr>
</table><script>$('table.PrintTable >tbody>tr>td').slice(-2).remove();</script>

The above JQuery removes the last two columns which is expected.

But, if I changed the code to:-

  function getBody(element)
    {
        var divider=2;
        var originalTable=element.clone();
        var newTable = ($(originalTable).children('tbody').children('tr').children('td')).slice(-1).remove();
        return $('<div>').append(newTable).html();
    }

 getBoby($('table.PrintTable'))

The above code displays only the last column. Why is it so? I hop I am able to mention my problem properly. Any help will be appreciated

  • 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-19T09:27:54+00:00Added an answer on May 19, 2026 at 9:27 am

    Based on your comment, it seems you want a duplicate of the original, but without the last two columns.

    Do this:

    function getBody(element) {
        var divider=2;
        var newTable = element.clone();
        newTable.children('tbody').children('tr').children('td').slice(-2).remove();
        return $('<div>').append(newTable).html();
    }
    
    getBody($('table.PrintTable'));
    

    In your code, newTable was referencing the portion of the clone that you sliced and removed. Not the main cloned table.

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

Sidebar

Related Questions

I`m really confused here about this weird behavior! The thing is, I have a
I'm confused by this behavior: I have an out-of-the-box MVC3 app. I haven't really
I'm really confused. I'm using Django 1.4 and I've been searching for this the
I am using Entity Framwwork and Code First and getting really confused. I have
I'm confused as to this behavior. Do I really need to split my array
Really confused why the QR output using RcppArmadillo is different than QR output from
I'm really confused, I just wrote this x = 0 y = 42 #Can
I am really confused about object relationships! I have two classes Person and Address.
I am totally confused with ArrayList behavior. Wrote really long post, then realized no
I found out really strange behavior on relatively simple use case, probably I can't

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.