15 lines
No EOL
336 B
JavaScript
15 lines
No EOL
336 B
JavaScript
var range;
|
|
|
|
function add(html, id) {
|
|
const old = document.getElementById(id)
|
|
if (old !== null) {
|
|
old.remove()
|
|
}
|
|
if (range === undefined) {
|
|
var range = document.createRange()
|
|
range.setStart(document.body, 0)
|
|
}
|
|
document.body.appendChild(
|
|
range.createContextualFragment(html)
|
|
)
|
|
} |