Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<html>
<head>
    <script type="text/javascript">
      var instance = 4;
    function newTextBox(element) {                
        instance++; 
        var newInput = document.createElement("input"); 
        newInput.id = "text" + instance; 
        newInput.name = "text" + instance; 
        newInput.type = "text"; 
        var div = document.createElement('div'); 
        div.appendChild(newInput); 
        document.body.insertBefore(div, element); 
    } 
    </script>
</head>
<body>
        <input id="text2" type="text" name="text1"/> <br>
        <input type="button" id="btnAdd" value="New text box" onclick="newTextBox(this);" />
</body>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers