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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:44:51+00:00 2026-05-31T04:44:51+00:00

this following code works in adding new rows in HTMl: function addRow() { var

  • 0

this following code works in adding new rows in HTMl:

function addRow() 
{
  var row = document.getElementById('row');
  var newRow = row.cloneNode(true);
  row.parentNode.insertBefore(newRow, document.getElementById('submit_row'));
}

How can I add a new function to remove a row? I tried searching but couldn’t find the answer.

  • 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-31T04:44:53+00:00Added an answer on May 31, 2026 at 4:44 am

    To remove a DOM element in Javascript you use the removeChild API. This requires you to have the DOM element of both the container and the item you want to remove.

    In this example if you wanted to remove the row with id row you would do the following

    var row = document.getElementById('row');
    row.parentNode.removeChild(row);
    

    Documentation: https://developer.mozilla.org/En/DOM/Node.removeChild

    Note: In this particular example it looks like you are adding multiple DOM nodes with the same id value. Having duplicate id values is not allowed and will cause you many problems down the road. Every id value needs to be unique.

    One way to accomplish this would be to use a counter to append a unique suffix to every row you add.

    var rowCounter = 0;
    function addRow() 
    {
      rowCounter++;
      var row = document.getElementById('row');
      var newRow = row.cloneNode(true);
      newRow.id = 'new_row_' + rowCounter;
      row.parentNode.insertBefore(newRow, document.getElementById('submit_row'));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did I not get enough sleep or what? This following code var frame=document.getElementById(viewer); frame.width=100;
following up from yesterday... This portion of the code does work. $(document).ready(function(){ $('#listMenu a').click(function
I have the following code, which works nicely: $('#register form .submit input').click(function(){ if(jQuery.trim($('#new-usr').val()) ==
I have the following code: Bear in mind that while this code works on
Never thought I'd have this problem :) The following snippet of code works in
The following code doesn't work! 'this' in in the context when i access it
How can I do this? (The following code does NOT work, but I hope
I have the following code in a shell script. This only seems to work
Work on this small test application to learn threading/locking. I have the following code,
I've got the following code: Regex.Replace(text, words.ToString(), <dfn title=\ + this.FindDefinition($0) + \>$0</dfn>, RegexOptions.IgnoreCase

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.