07.31《jQuery》——3.2文件上传、添加删除文件域

点击more按钮添加一个文件域、remove按钮

点击remove按钮移除对应的文件与和remove按钮

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script src="../jquery-3.2.1/jquery-3.2.1.js"></script>
        <script type="text/javascript">
            $(function(){
                $("#btn1").click(function(){
                    
                    var file = $("<input type = 'file' />");
                    var button = $("<input type = 'button' value = 'remove' />");
                    var br = $("<br/>");
                        button.click(function(){
                            file.remove();
                            button.remove();
                            br.remove();
                        });
                    $("#div1").append(file);
                    $("#div1").append(button);
                    $("#div1").append(br);
                });
            });    
        </script>
    </head>
    <body>
        <div id="div1">
            <input type="file" />
            <input type="button" name="btn1" id="btn1" value="more" />
            <br />
        </div>
    </body>
</html>

 

posted @ 2018-08-01 00:46  微光TeaRs  阅读(442)  评论(0编辑  收藏  举报