Jump to content
Eido96

DOM element outerHTML attribute JavaScript reference

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...