[HTML 5] Inserting DOM element
2021-04-03 08:28
标签:app const after inner node append script tno span [HTML 5] Inserting DOM element 标签:app const after inner node append script tno span 原文地址:https://www.cnblogs.com/Answer1215/p/12541990.htmlconst app = document.getElementById(‘app‘);
app.innerHTML = `
JavaScript DOM
`;
const div = document.createElement(‘div‘);
const span = document.createElement(‘span‘);
const p = document.createElement(‘p‘);
const i = document.createElement(‘i‘);
const b = document.createElement(‘b‘);
div.append(span);
div.prepend(p);
// p.before(i);
p.after(i);
// Before: old way using insertBefore
// i.parentNode.insertBefore(b, i);
// After: old way using insertBefore + nextSibling
i.parentNode.insertBefore(b, i.nextSibling);
console.log(div);
文章标题:[HTML 5] Inserting DOM element
文章链接:http://soscw.com/index.php/essay/71742.html