Skip to content

I forgot about el.outerHTML so I made this, it takes a DOM element and returns its html as string

Notifications You must be signed in to change notification settings

0shuvo0/htmlToString

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

htmlToString explaination meme

htmlToString

Convert html/DOM element to string

Works with rendered and virtual DOM

Installation

npm install htmltostring

Or using CDN

<script src="https://cdn.jsdelivr.net/npm/htmltostring@1.0.6/htmlToString.min.js"></script>

Usage

//you don't have to import if you're using CDN
import htmlToString from 'htmltostring'

console.log(htmlToString('.container'))
// or 
// const container = document.querySelector('.container')
// console.log(htmlToString(container))

Example Output

<div class="container">
    <h1>Hello World</h1>
</div>

About

I forgot about el.outerHTML so I made this, it takes a DOM element and returns its html as string

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published