Take html from a tag, including the tag itself

Asked

Viewed 69 times

1

How would I get a piece of my html along with the tags? For example:

duvida

I wanted to get this span inside the TD, in case I wanted it all together, up to the tag <span>, drew?

1 answer

2

With pure Javascript, just grab the outerHTML element. For example, for that span:

var span = document.querySelector('#play1_3_2');
var html = span.outerHTML;
console.log(html);
<span id="play1_3_2"></span>

  • What would be the outerHTML?

  • 1

    The outerHTML is the innerHTML + the tag itself (including attributes).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.