请问我用js动态创建DOM节点,为什么不起作用?代码如下:
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><title>js_test04...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>js_test04.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
window.onload = function(){
var newInput = document.createElement("input");
newInput.type = "text";
newInput.value = "newNode";
newInput.className = "in";
}
</script>
<style type="text/css">
.in{
border:3px solid blue;
}
</style>
</head>
<body>
</body>
</html> 展开
<html>
<head>
<title>js_test04.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
window.onload = function(){
var newInput = document.createElement("input");
newInput.type = "text";
newInput.value = "newNode";
newInput.className = "in";
}
</script>
<style type="text/css">
.in{
border:3px solid blue;
}
</style>
</head>
<body>
</body>
</html> 展开
2015-01-30
展开全部
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>menu</title>
<style type="text/css">
.in {
border: 3px solid blue;
}
</style>
<script type="text/javascript">
window.onload = function ()
{
var newInput = document.createElement ("input");
newInput.type = "text";
newInput.value = "newNode";
newInput.className = "in";
document.body.appendChild (newInput);
}
</script>
</head>
<body>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询