利用js的追加 appendChild实现评论
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<button onclick="ck()">追加</button>
<script>
function ck() {
let oDiv = document.createElement('div');
// 追加
// 父元素.appendChild(子元素)
oDiv.innerHTML = 'hello wordl';
document.body.appendChild(oDiv);
oDiv.style = 'width:100px;height:100px;background:#09f';
// document.write('<h1>hello world</h1>')
}
/*
小结:
document.createElement('标签名')
父元素.appendChild(子元素)
*/
</script>
</body>
</html>
最后
以上就是笨笨身影最近收集整理的关于原生JS实现评论功能的全部内容,更多相关原生JS实现评论功能内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复