可以呀
<body>
<div id="tt">abc</div>
<input type="button" value="click" onclick="t()">
<script>
function t() {
  tt.innerHTML += "<input type=button value=dclick onclick=t2()>";
}
function t2(){
alert("hi");//test
}
</script>
</body>

解决方案 »

  1.   

    而且你为什么写两次那
    <html>
    <body>
    </body>
    <script language="javascript">
    window.onload=function() {
    var i=1;
    var sb="<form name=smj onkeydown=if(event.keyCode==13){event.keyCode=9;}>"
    document.body.innerHTML+=sb;var sb1="<td><input type=text name=name"+i+"></td>";
    var sb2="<td><input type=text name=age"+i+"></td>";
    var sb3="<td><input type=text name=city"+i+"></td>";document.body.innerHTML+=sb1;
    document.body.innerHTML+=sb2;
    document.body.innerHTML+=sb3;
    }
    </script>
    </html>
      

  2.   

    flashsoft2000(FS2K)老师:!!!您给我的代码连用回车键代替Tab键的功能都没有了!当然就更谈不上我希望的在生成的最后一个<input name=city ...  >框中按下回车键后,在页面上自动增加一行了
      

  3.   

    给script 加上defer就可以让innerHTML执行脚本DEFER Attribute | defer Property--------------------------------------------------------------------------------Sets or retrieves the status of the script.SyntaxHTML <SCRIPT DEFER ... >  
    Scripting SCRIPT.defer [ = bDefer ] Possible ValuesbDefer Boolean that specifies or receives one of the following values:false Default. Inline executable function is not deferred. 
    true Inline executable function is deferred. 
     The property is read/write. The property has a default value of false.Expressions can be used in place of the preceding value(s), as of Microsoft&reg; Internet Explorer 5. For more information, see Dynamic Properties.ResUsing the attribute at design time can improve the download performance of a page because the browser does not need to parse and execute the script and can continue downloading and parsing the page instead. 
      

  4.   

    yonghengdizhen(风儿她轻轻的吹) :能不能详细点。
    defer怎么用?