2024-05-08 10:14:43 -04:00
|
|
|
<html>
|
|
|
|
<body>
|
|
|
|
<b id="test">Test</b>
|
|
|
|
|
|
|
|
<div id="container">
|
|
|
|
<div id="d">This is a div.</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function aa()
|
|
|
|
{
|
|
|
|
var a1 = document.getElementById('test').outerHTML;
|
|
|
|
console.assert(a1 === '<b id="test">Test</b>', a1);
|
|
|
|
}
|
|
|
|
|
|
|
|
function bb()
|
|
|
|
{
|
|
|
|
const container = document.getElementById("container");
|
|
|
|
const d = document.getElementById("d");
|
|
|
|
console.assert(container.firstElementChild.nodeName === 'DIV', 'DIV');
|
2024-05-08 12:32:59 -04:00
|
|
|
d.outerHTML = '<p>' + d.outerHTML + '</p>';
|
2024-05-08 10:14:43 -04:00
|
|
|
console.assert(container.firstElementChild.nodeName === 'P', 'P');
|
2024-05-08 12:32:59 -04:00
|
|
|
console.assert(container.innerHTML === '\n <p></p><div id="d">This is a div.</div><p></p>\n', 'div p div');
|
2024-05-08 10:14:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
console.error('element.outerHTML.html');
|
|
|
|
aa();
|
|
|
|
bb();
|
|
|
|
console.exit(0);
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|