document.getElementById("input").innerHTML += "<input type=submit onclick='alert(\"hi\")'>"

解决方案 »

  1.   

    好象可以达到效果 但能不能更动态一点
    比如createElement() 然后再在这个ele里增加一个attribute
    我就是不知道这个attribute应该如何写
      

  2.   

    直接
    o=document.createElement("input") ;
    o.type="button";
    o.onclick=function(){
    alert(this.tagName);
    }
    div1.appendChild(o);
      

  3.   

    createElement  addEventListener
    关键是上面两个函数的应用
      

  4.   

    TO: LCKKING(名花美人剑¢无香自流仙) 
    DOM效率不高能说说为什么吗?