动态创建按钮的JS

时间:2020-12-16 07:38:56

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE>创建动态按钮</TITLE>
  <META NAME="Email" CONTENT="
798033502@qq.com">
  <META NAME="Author" CONTENT="MXi4oyu">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <script type="text/javascript">
  function show()
  {
   var mydiv=document.getElementById("mydiv");
   var input =document.createElement("input");
   input.type="button";
   input.value="动态按钮";
   mydiv.appendChild(input)
  }
  </script>
 </HEAD>

 <BODY>
 <div id="mydiv">
  <input id="btnReg" type="button" value="创建" onclick="show()" />
</div>
 </BODY>
</HTML>