snippet-from-dom-element
v0.5.2
Published
This tool to get a snippet from the dom element. The snippet has original open-close HTML tag with attributes and truncated inner text.
Downloads
1
Readme
Snippet from dom element
Description
This tool to get a snippet from the dom element. The snippet has original open-close HTML tag with attributes and truncated inner text.
Install
For npm:
npm install --save snippet-from-dom-element
For yarn:
yarn add snippet-from-dom-element
Example
import getSnippetFromDomElement from 'snippet-from-dom-element'
const element = document.querySelector('#main-news-title');
const innerContentLength = 10;
const snippet = getSnippetFromDomElement(element, innerContentLength);
console.log(snippet);
// <h2 id="main-news-title">Breaking n...</h2>