JavaScript Program to Append Child at Runtime

Write a JavaScript program to append child at runtime.



Source Code
<html>

<head>
    <title>Append Child at Runtime</title>
    <script type="text/javascript">
        function addChild() {
            ev = document.createElement("input")
            ev.type = "file"
            d = document.getElementById("mydiv")
            d.appendChild(ev)
            br = document.createElement("br")
            d.appendChild(br)
        }
    </script>
</head>

<body>
    <input type="button" value="Add" onclick="addChild()" />
    <div id="mydiv">

    </div>
</body>

</html>
Output