22 lines
No EOL
456 B
JavaScript
22 lines
No EOL
456 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)
|
|
)
|
|
}
|
|
|
|
function remove(id) {
|
|
const old = document.getElementById(id)
|
|
if (old !== null) {
|
|
old.remove()
|
|
}
|
|
} |