<span style="color: #008000;">//</span><span style="color: #008000;"> HTML:</span><span style="color: #008000;">
//</span><span style="color: #008000;"> <div id="container"><div id="d">This is a div.</div></div></span>
<span style="color: #000000;">
container </span>= document.getElementById("container"<span style="color: #000000;">);
d </span>= document.getElementById("d"<span style="color: #000000;">);
console.log(container.firstChild.nodeName); </span><span style="color: #008000;">//</span><span style="color: #008000;"> logs "DIV"</span>
<span style="color: #000000;">
d.outerHTML </span>= "<p>this paragraph replaced the original div.</p>"<span style="color: #000000;">;
console.log(container.firstChild.nodeName); </span><span style="color: #008000;">//</span><span style="color: #008000;"> logs "P"</span>
<span style="color: #008000;">//</span><span style="color: #008000;"> The #d div is no longer part of the document tree,</span><span style="color: #008000;">
//</span><span style="color: #008000;"> the new paragraph replaced it.</span>While the element will be replaced in the document, the variable whose outerHTML property was set will still hold a reference to the original element!
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Basic support | 4 | 45 (45) | 6 | 9.6 (probably earlier) | 3 |
t[t.innerText ? 'innerText' : 'textContent'] = v.n
立即学习“前端免费学习笔记(深入)”;
立即学习“前端免费学习笔记(深入)”;
it = currHeaderChildNodes[i].innerText || currHeaderChildNodes[i].textContent;
立即学习“前端免费学习笔记(深入)”;
立即学习“前端免费学习笔记(深入)”;
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号