javascript - js document.getElementByClassName("").appendChild(); 的问题
问题描述
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
let exmpale = document.createElement("div");
exmpale.innerHTML = "aaaaa";
exmpale.className = "classDiv";
document.getElementsByClassName("myDIV").appendChild(exmpale);
}
</script>
</head>
<body>
<div class="myDIV">
A DIV
</div>
<button onclick="myFunction()">button</button>
</body>
</html>
我不知道为什么,但是当我单击按钮时,它不会打印出innerHTML
(aaaaa) 中的值。
解决方案
推荐阅读
- jquery - 水平滚动时,DataTables Fixed Column 上的 Popover 看起来很奇怪
- node.js - 将 AppService 连接到虚拟机
- python - 有没有办法像基于图像的示例一样调整 CNN 的非图像文件的大小?
- javascript - Fancybox 忽略拇指选项
- c# - 点网的 Splunk 配置
- sqlite - 未触发 TypeORM 挂钩,包括最小项目
- java - 在 VSCode 中编译 java 类
- javascript - 跳出 if 语句
- python - 在python中用于网络抓取的for循环
- wordpress - 我可以使用 add_action 或 add_filter 在 Wordpress 管理表视图 (WP_List_Table) 中显示是或否而不是 0 或 1?