Get html from a tag, including the tag itself

1

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

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

    
asked by anonymous 23.11.2017 / 01:55

1 answer

2

With pure JavaScript, just grab the outerHTML element. For example, for this your span:

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