HTML DOM HR 对象
HTML DOM 的 HR 对象表示 HTML 文档的 <hr> 元素。
创建 hr 对象−
语法
以下为语法 −
document.createElement(“HR”);
让我们看一个 hr 对象的示例−
示例
<!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;
}
hr {
border-color: #db133a;
}
</style>
<body>
<h1>DOM hr Object Demo</h1>
<button onclick="createHr()" class="btn">Create a hr object</button>
<script>
function createHr() {
var insElement = document.createElement("HR");
document.body.appendChild(insElement);
}
</script>
</body>
</html>输出

单击“创建 hr 对象”按钮以创建一个 hr 对象。

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP