This morning I needed to convert a DOM element into a sting. And at the time I forgot about the el.outerHTML method. And I know the el.innerHTML will not include in element itself. It will only give inner HTML. So after doing a quick Google I was remined about the outerHTML method. And my issue was solved!
But this got me thinking how could I do it if there was no innerHTML or outerHTML method.
And thus htmlToString was born.
//you don't have to import if you're using CDNimporthtmlToStringfrom'htmltostring'console.log(htmlToString('.container'))// or // const container = document.querySelector('.container')// console.log(htmlToString(container))