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 对象。
相关用法
- HTML DOM HTML用法及代码示例
- HTML DOM Heading用法及代码示例
- HTML DOM Header用法及代码示例
- HTML DOM History length属性用法及代码示例
- HTML DOM Style overflowY属性用法及代码示例
- HTML DOM Document hidden属性用法及代码示例
- HTML DOM IFrame用法及代码示例
- HTML DOM Textarea cols属性用法及代码示例
- HTML DOM Style pageBreakAfter属性用法及代码示例
- HTML DOM Base href属性用法及代码示例
- HTML DOM Pre用法及代码示例
- HTML DOM Input Month用法及代码示例
- HTML DOM Video canPlayType()用法及代码示例
- HTML DOM Range deleteContents()用法及代码示例
- HTML DOM console.dirxml()用法及代码示例
- HTML DOM Style transition属性用法及代码示例
- HTML DOM Video volume属性用法及代码示例
- HTML DOM Input Range用法及代码示例
- HTML DOM Style outlineOffset属性用法及代码示例
- HTML DOM Storage setItem()用法及代码示例
注:本文由纯净天空筛选整理自AmitDiwan大神的英文原创作品 HTML DOM HR Object。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。