<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<title> New Document </title>

<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">

<script language="JavaScript" type="text/JavaScript">
function addbut(){
var container=document.getElementById("div1");
var frag = document.createDocumentFragment();
for (var i=0;i<10;i++)
{
var btn = document.createElement("input");
btn.type="button";
btn.value="nuw Button"
frag.appendChild(btn);
}
container.appendChild("frag");
}
</script> </head> <body onload="addbut()">
<div id="div1"> hello</div>
</body>
</html>
   然后chrom调试    DOM exception 8了~~~~~~什么情况?    刚学JS。这类问题怎么解决~?谢谢您啦!

解决方案 »

  1.   

    这句有问题,应改为
    container.appendChild(frag);
      

  2.   

    container.appendChild("frag");
    传参不要用引号,引号表示字符串。
      

  3.   

    。好吧,,,,我2了!!!!!!!且不管这个小问题,,还想请教下,像dom exception 8 这种错误一类的什么意思?
      

  4.   

    。好吧,,,,我2了!!!!!!!且不管这个小问题,,还想请教下,像dom exception 8 这种错误一类的什么意思?
      

  5.   

    属于文档对象异常的一种,
    微软解释为:DOMException.NOT_FOUND_ERR 8 The specified node cannot be found. 
    http://technet.microsoft.com/zh-cn/library/gg592979像你这种错误,一般是由于拼写错误或语法问题导致