JSFiddle - React, Tailwind, and code Playground

by David Thomas

HTML

<div id="abc" data-attr="A custom data-* attribute">Some text in the div.</div>

JavaScript

var htmlString = document.getElementById('abc').outerHTML;
console.log(htmlString);