div是个块tag,它的style.display默认是block,在代码的以下这一句后面加一句再试试看:var newArea = document.createElement('div');
---->>>>
var newArea = document.createElement('div');
newArea.style.display="inline";//加上这一句

解决方案 »

  1.   

    我再机器上重新运行了了一下,没有发现你说的问题,很正常!
    代码如下
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var fileCount=0;
    function addFile() {
            if (fileCount < 5) {
                fileCount++;
                var newArea = document.createElement('div');
                newArea.id = 'fileuparea' + fileCount;var newFile = document.createElement('input');
    newFile.type = 'file';
                newFile.name = 'fileupanme'+fileCount;
                newFile.id = 'fileup' + fileCount;

    var newFileDel = document.createElement('a');
    newFileDel.href = "javascript:delMyFile('fileuparea"+fileCount+"');";
                newFileDel.name = 'filedelname'+fileCount;
                newFileDel.id = 'filedel' + fileCount;
    var txtnode=document.createTextNode("删除");
    newFileDel.appendChild(txtnode);      newArea.appendChild(newFile);
    newArea.appendChild(newFileDel);            document.getElementById('upload').appendChild(newArea);
            } else alert("上传太多!");
        }//-->
    </SCRIPT>
    <BODY>
    <div id="upload"></div>
    <INPUT TYPE="button" value="create" onclick="addFile()">
    </BODY>
    </HTML>
      

  2.   

    感谢zhaoxiaoyang,mqcan对代码的理解,谢谢CutBug,JK_10000的指点,问题已经解决了,就像zhaoxiaoyang,mqcan所说的那样,代码没有问题,就是没注意head部分定义的css
    input {
        display: block;
        margin-bottom: 2px;
    }晕倒....