HTML DOM Strong 对象
htmlweb developmentfront end technology更新于 2024/5/26 16:44:17
HTML DOM Strong 对象与 HTML <strong> 元素关联。strong 标签用于强调文本,使其加粗。我们可以分别使用 createElement() 和 getElementById() 方法创建和访问 strong 元素。
语法
以下是语法 −
创建 strong 对象 −
Var s= document.createElement("STRONG");
示例
让我们来看一个 strong 对象的示例 −
<!DOCTYPE html>
<html>
<body>
<h1>Strong object example</h1>
<p>Create a strong element by clicking the below button</p>
<button onclick="createStrong">CREATE</button>
<p>This is some text inside the p element</p>
<script>
function createStrong() {
var s = document.createElement("STRONG");
var txt = document.createTextNode("This is some text inside the strong element");
s.appendChild(txt);
document.body.appendChild(s);
}
</script>
</body>
</html>
输出
这将产生以下输出 −

点击"创建"按钮 −

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

