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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:15:09+00:00 2026-06-15T14:15:09+00:00

I have to remove certain tr which have a particular class in a table..I

  • 0

I have to remove certain tr which have a particular class in a table..I tried the below stuff but it does not seem to work

var d1 = document.getElementsByClassName("t1");
    for (var i = 0; i < d.length; i++) {
        d1[i].parentElement.removeChild(d1[i]);
    }

Can someone please guide me in the right direction

<html>
    <head>
        <script type="text/javascript">
            function removeTR (){
            }
        </script>
    </head>
    <body onload="javascript:removeTR()">
        <table>
            <tr >
                <td></td>
            </tr>
            <tr class="t1">
            </tr>
            <tr class="t1">
            </tr>
        </table>
    </body>
</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-06-15T14:15:10+00:00Added an answer on June 15, 2026 at 2:15 pm

    You have a few typo and another more fundamental problem : you can’t iterate this way and remove at the same time on a dynamic collection (a live NodeList) as returned by getElementsByTagName.

    var d = document.getElementsByClassName("t1");
    for (var i = 0; i < d.length; i++) {
        d[i].parentElement.removeChild(d[i]);
    }
    

    At second iteration you would try to remove element at index 1 but there still would be an element at index 0 which thus would never be removed.

    A solution is this :

    var d = document.getElementsByClassName("t1");
    while (d.length) d[0].parentElement.removeChild(d[0]);
    

    Demonstration

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

Sidebar

Related Questions

I have markup which I would like to remove/transform certain tags from, but retain
I have a string which I need to remove certain characters from. string note
I have server service which releases the table database if a certain criterian is
I have a full path which I would like to remove certain levels of
I have installed Windows XP after using nlite to remove certain unneeded components. I
I have a ParameterInfo array. I need to remove certain values from the array.
I have a string. How do I remove all text after a certain character?
I have remove some item from the list of the BxSlider carousel. But when
I have parent pom which configures certain plugins <pluginManagement> </plugins> <plugin> <artifactId>gmaven-plugin</artifactId> ... </plugin>
I have a dictionary dict2 which I want to iter through and remove all

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.