css-selector-to-js-inserter
v1.0.0
Published
An npm package that can transpile a css selector and a html snippet to a javascript inserter method.
Downloads
10
Maintainers
Readme
css-selector-to-js-inserter
This npm package provides a function cssSelectorToJsInserter
that takes a CSS selector and an HTML snippet as arguments and returns a JavaScript function that inserts the HTML snippet into the DOM at the location specified by the CSS selector.
Installation
To install this package, run the following command:
npm install css-selector-to-js-inserter
Usage
To use this package, import the cssSelectorToJsInserter
function from the package and call it with a CSS selector and an HTML snippet. The function will return a JavaScript function that can be called to insert the HTML snippet into the DOM at the location specified by the CSS selector.
import { cssSelectorToJsInserter } from 'css-selector-to-js-inserter';
const insertHtml = cssSelectorToJsInserter('#my-element', '<p>Hello, world!</p>');
insertHtml();
Types
This package exports the following types:
CssSelector
: a string representing a CSS selectorHtmlSnippet
: a string representing an HTML snippetJsInserter
: a function that takes no arguments and returns void
Contributing
Contributions are welcome! Please open an issue or pull request on the GitHub repository.
License
This package is licensed under the MIT License. See the LICENSE file for details.