在本文中,我将解释在JavaScript中DOM对象的CreateComment()方法。
JavaScript Window对象CreateComment()方法
JavaScript CreateComment()方法用于创建具有指定给定文本的注释节点。
语法
document.createComment(text)
JavaScript Window对象CreateComment()方法示例
<html>
<head>
<script type="text/javascript">
function myfun() {
var mm = document.createComment("注释内容");
document.body.appendChild(mm);
var pp = document.getElementById("txt");
pp.innerHTML = "正文";
};
</script>
</head>
<body>
点击按钮创建注释
<button onclick="myfun()">
点击</button>
</body>
</html>
日期:2020-04-18 01:09:20 来源:oir作者:oir
