Jump to content

Recommended Posts

Posted

My suggestion is to add HTML DOM element object outerHTML attribute for the JavaScript reference.

 

It seems that most, if not all, the browsers support this attribute.

 

In addition, it is important and basic attribute that new JavaScript developers should know about.

  • Like 1
Posted

I actually don't think it's important. It has the potential to mess up the DOM. I have never had a need for it.

  • 1 year later...
Posted

I have had a need for it, and it is very important.  I use it to copy the last row of a table to add a new row.  It saves the user a lot of work.  It's a lot easier than a "work around."

Posted

There's a more correct way to do that.  The table element has a rows property that contains a collection of all of the rows:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement

You can access the last row element and then use cloneNode to create a copy, and then appendChild to add it as a child of the tbody.

https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode

You can also use the DOM methods to create a new row and add cells to it:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/insertRow

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...