这个在ie下删除(d.setAttribute("onclick", "deteFile(this)");)没有实现,在ff下可以,问怎么修改才可以在ie下实现
<script type="text/javascript">
    function addFile() {
      var div = document.createElement("div");
      var f = document.createElement("input");
      f.setAttribute("type", "file")
      f.setAttribute("name", "File")
      f.setAttribute("size", "50")
      div.appendChild(f)
      var d = document.createElement("input");
      d.setAttribute("type", "button")
      d.setAttribute("onclick", "deteFile(this)");
      d.setAttribute("value", "移除")
      div.appendChild(d)
      document.getElementById("_container").appendChild(div);
    }    function deteFile(o) {
      while (o.tagName != "DIV") o = o.parentNode;
      o.parentNode.removeChild(o);
    }
    
  </script>

解决方案 »

  1.   

    d.setAttribute("onclick", "deteFile(this)");
    这句确实有兼容性问题
    请尝试使用attachEvent来做
    d.attachEvent("onclick","deteFile(this)");
    而在ff下可以使用你的setAttribute也可以使用addEventListener
      

  2.   

    d.onclick = "deteFile(this)";
    这样试试看
      

  3.   

    错了..
    试试看这样的 
     d.setAttribute("onclick", "\"deteFile(this)\"");
      

  4.   

    正解
    GOOGLE下
    addEventListener  attachEvent 就明白了
      

  5.   

    d.onclick=function(){deteFile(this);};
      

  6.   


    使用这个会JavaScript出错
    d.setAttribute("onclick", "\"deteFile(this)\"");  这个也实现不了