var str;
var sp=document.createElement("span");
sp.innerHTML=str;
//显示你想要的值
var test=document.getElementById("test");
test.appendChild(sp);

解决方案 »

  1.   

    <head><script>
     var html="<a href='javascript:;' onclick=\"remove(this)\">删除</a>";
     var attachname = "attach";  
     var i=1;
        function addInput()     {
          if(i>0){  
                 var attach = attachname+i;  
                 if(createInput(attach))  
                 {
                      i=i+2;  
                 }
         }  
        }
    function createInput(nm)

     var div=document.createElement("div");
     var  aElement=document.createElement("input");     
         aElement.name=nm;  
         aElement.id=nm;  
         aElement.type="file";  
         aElement.size="10"; 
         var Div=document.createElement("div");
         var o=document.getElementById('a');
      o.appendChild(Div);
      Div.appendChild(div);
     if(div.appendChild(aElement)==null)return false;
     div.style.display="none";
     div.childNodes[0].click();
      var why=document.getElementById(nm).value;
      var s=why.split("\\");
      var len=s.length;
      if(s[len-1].length!=0)
      {
      var sp=document.createElement("span");
         sp.innerHTML=s[len-1]+html;
         
         Div.appendChild(sp);
      } 
      var files=document.createElement("input");
         files.type="button";
         Div.appendChild(files);
      return true;
     }
        
        function remove(obj)     {     obj.parentElement.parentElement.removeChild(obj.parentElement);     } 
    </script>
    </head>
    <body class="All_C_Page Inbox">
    <div>
    <input type="button" onClick="addInput();" value="添加附件">
    </div>
    <div id="a"></div>
    </body>我代码是这样的 但当我点击添加附件再选择一个文件的时候 想让他在页面中显示文件名 
    结果在其他浏览器中显示不了 换成ie就可以了 
    不知道怎么解决