HTML DOM Underline 下划线对象
htmlweb developmentfront end technology更新于 2024/3/21 13:32:17
HTML 中的 HTML DOM 下划线对象代表 <u> 元素。
创建 <u> 元素
var uObject = document.createElement(“U”)
让我们看一个 Underline 元素的示例 −
示例
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Underline</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-Underline</legend>
<h2 ><u id="Underline">Warning: </u>This is a Demo Example</h2>
<input type="button" value="Show" onclick="getBetterDisp()">
</fieldset>
</form>
<script>
var uObject = document.getElementById("Underline");
function getBetterDisp() {
uObject.style.backgroundColor = '#DC3545';
uObject.style.color = '#FFF';
}
</script>
</body>
</html>
输出
点击显示按钮之前 −

点击显示按钮之后 −

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

