Jump to content

DOM element outerHTML attribute JavaScript reference


Eido96

Recommended Posts

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
Link to comment
Share on other sites

  • 1 year later...

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

Link to comment
Share on other sites

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...