<table border=1><tr>
<TD id="td1" onclick="f()"></TD>
</tr></table><SCRIPT LANGUAGE="JavaScript">
function f()
{
   var obj = document.getElementById("td1");
   obj.innerHTML = "<DIV id = \"div1\">this is div1...</DIV>";
}
</SCRIPT>

解决方案 »

  1.   

    我的div中有select控件,上有事件的,我想一起显示出来。
      

  2.   

    <table border=1><tr>
    <TD id="td1" onclick="f()"></TD>
    </tr></table><SCRIPT LANGUAGE="JavaScript">
    var i = 0;
    function f()
    {
       if(i==0){
          var obj = document.getElementById("td1");
          html = "<DIV id = \"div1\"><SELECT NAME=\"sel1\" onchange=\"alert(this.options[this.selectedIndex].value)\">";
          html = html + "<OPTION VALUE=1>1</OPTION>";
          html = html + "<OPTION VALUE=2>2</OPTION>";
          html = html + "</SELECT></DIV>";
          obj.innerHTML = html;
          i = 1;
       }
    }
    </SCRIPT>
      

  3.   

    能请教一下:这句该如何改document.getElementById("div1").style.offsetLeft = 300;
      

  4.   

    TRY:
    <table border="1">
    <tr>
    <td id="t1"></td>
    </tr>
    </table>
    <p>
    <input type="button" value="Try" onclick="addsth();">
    <script language="javascript">
    function addsth(){
    var oDiv = document.createElement("DIV");
    oDiv.id = "div1";
    oDiv.innerHTML = "<select id=\"st\" onchange=\"alert(this.selectedIndex);\"><option>ct-001<option>ct-002<option>ct-003</select>";
    t1.appendChild(oDiv);
    }
    </script>