0

我知道如何在 HTML 中创建一个按钮,但是我将如何创建一个 JavaScript 函数,当按下该按钮时它会不断创建多个按钮并不断将它们添加到屏幕上?

   <script>
    function repeats() {
            ?
    }
   </script
   <input id ="addsubmit"  type="submit" value= "Submit" style = "margin-top: 25px;">
   </input>
4

1 回答 1

1

给你 - 请让我知道这是你要求的:-)

<html>
<head>
<script language="javascript">
    function repeats() {
        document.getElementById('buttons').innerHTML += '<input id ="addsubmit" onclick="repeats()";  type="submit" value= "Submit" style = "margin-top: 25px;">';
    }
</script>
</head>

<body>
 <input id ="addsubmit" onclick="repeats()";  type="submit" value= "Submit" style = "margin-top: 25px;">
     </input>
     <div  id="buttons">buttons here: </div>
</body>
</html>
于 2012-10-22T00:44:10.240 回答