复制的源码,为什么我的火狐浏览器还是一片空白
<script type="text/javascript"> var body = document.body; var input = document.createElement("input");
input.type = "button";
input.value = "创建一个按钮";
body.appendChild(input);
</script>
<script type="text/javascript"> var body = document.body; var input = document.createElement("input");
input.type = "button";
input.value = "创建一个按钮";
body.appendChild(input);
</script>
整体放在<body>标签内就显示了,关于是为什么 我也在问,现在还没有答案
<html> <head> <meta charset="UTF-8"> <title>title</title> <script type="text/javascript"> function add() { var body = document.body; var input = document.createElement("input"); input.type = "button"; input.value = "创建一个按钮"; body.appendChild(input); } </script> </head> <body> <input type="button" value="add" onclick="add()"/> </body> </html>