Insert string into HTML.
$ npm install --save insert2
import insert from 'insert2'
const html = `
<html>
<head>
<title>hi</title>
</head>
<body>
</body>
</html>
`
insert(html, {
string: '<link rel="stylesheet" href="style.css" />',
el: 'head'
})
// returned
<html>
<head>
<title>hi</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
</body>
</html>
Type: string
Default: ''
The original HTML string.
Type: String
Default: ''
The string to be inserted into HTML.
Type: String
Default: body
HTML tag name, the place to insert into.
Type: String
Default: append
append
or prepend
.
Like insert2() but uses a list of options to do multiple insertions.
import {insertMulti} from 'insert2'
MIT © EGOIST