首页 > 代码库 > jquery 添加html标签

jquery 添加html标签

 

 

<script type="text/javascript">
        var sss = 1;
        function addFile() {
            if (sss < 20) {
                var str =  <span id = row + sss + ><br/><INPUT type="file" style="WIDTH: 222px; HEIGHT: 20px" size="50" NAME="File">&nbsp;<span style="line-height:25px;">文件说明:<input type="text" id="pic + sss + " name="pic + sss + " value="" style="WIDTH: 322px; HEIGHT: 20px" size="50"   /><a href="http://www.mamicode.com/#" onclick=deleteRow(row + sss + )>删除<a/></span>;
                document.getElementById(P1).insertAdjacentHTML("beforeEnd", str);
            }
            else {
                alert("您一次最多只能上传20个文件!");
            }
            sss++;
        }

        function deleteRow(e) {
            //alert("成功删除第" + e + "行");
            var obj = document.getElementById(e.id);
            //    obj.removeNode(e);
            obj.remove(e);
            sss--;
        }

    </script>
View Code

 

 1 <style type="text/css">
 2         .isbnt
 3         {
 4             float: left;
 5             margin-left: 10px;
 6         }
 7         .bnt
 8         {
 9             margin: 0 auto;
10             width: 500px;
11             height: 20px;
12         }
13     </style>
View Code

 

 

 

       <tr>
                    <th>
                        文 件:
                    </th>
                    <td colspan="5">
                        <p id="P1">
                            <input id="file" style="width: 222px;" type="file" size="42" name="File1" runat="server" />
                            <span>文件说明:
                                <input type="text" id="pic0" name="pic0" value="" style="width: 322px;" size="50" /></span>
                        </p>
                        <input type="button" value="http://www.mamicode.com/继续上传" onclick="addFile()" style="width: 69px; height: 20px" />
                    </td>
                </tr>