HTML-Code:
<!DOCTYPE html> <html lang="de"> <head> <meta charset="utf-8" /> <title>Demo</title> <script type="text/javascript"> /*<![CDATA[*/ function newBox() { var hin = document.getElementById("hin"), input = document.createElement("input"), newline = document.createElement("br"); input.setAttribute("type", "text"); input.setAttribute("name", "head[]"); hin.appendChild(input); hin.appendChild(newline); } window.onload = function () { document.getElementById('demo').onclick = function () { newBox(); }; }; /*]]>*/ </script> </head> <body> <button id="demo">Hinzufügen</button> <div id="hin"></div> </body> </html>
Kommentar