HTML DOM Aside 对象
htmldomweb developmentfront end technology更新于 2025/12/28 0:12:17
HTML DOM Aside 对象表示 HTML 文档的 <aside> 元素。
创建 aside 对象 −
语法
以下是语法 −
document.createElement(“ASIDE”);
让我们看一个 aside 对象的示例−
示例
<!DOCTYPE html>
<html>
<style>
body {
text-align: center;
background-color: #fff;
color: #0197F6;
}
h1 {
color: #23CE6B;
}
.btn {
background-color: #fff;
border: 2px solid #0197F6;
height: 2rem;
width: 40%;
margin: 2rem auto;
display: block;
color: #0197F6;
outline: none;
cursor: pointer;
border-radius: 20px;
}
aside {
border: 1.5px solid #db133a;
padding: 20px;
}
</style>
<body>
<h1>DOM aside Object Demo</h1>
<button onclick="createAside()" class="btn">Create a aside object</button>
<script>
function createAside() {
var asideElement = document.createElement("ASIDE");
asideElement.innerHTML = 'I\'m an aside element<h3>This is a h3 element inside an aside element</h3><p>This is a paragraph element inside an aside element</p>';
document.body.appendChild(asideElement);
}
</script>
</body>
</html>
输出

点击“创建 aside 对象”按钮来创建 aside 对象。

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

