示例-添加删除附件

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>添加删除附件</title>
 6 <style type="text/css">
 7     table a:link,table a:visited{
 8         color:#179ed9;
 9         text-decoration:none;
10         }
11     table a:hover{
12         color:#f36021;
13         }
14 </style>
15 </head>
16 
17 <body>
18 
19     <script type="text/javascript">
20         function addFile(){
21             /*
22             *因为文件选取框定义在行对象中。
23             *所以只要给表格创建新的行和单元格即可。
24             */
25             var oTabNode = document.getElementById("fileid");
26             
27             var oTrNode = oTabNode.insertRow();
28             
29             var oTdNode_file = oTrNode.insertCell();
30             var oTdNode_del = oTrNode.insertCell();
31             
32             oTdNode_file.innerHTML = "<input type='file' />";
33             oTdNode_del.innerHTML = "<a href='javascript:void(0)' οnclick='deleteFile(this)' />删除附件</a>";
34             
35             }
36             
37             function deleteFile(node){
38                 var oTrNode = node.parentNode.parentNode;
39                 oTrNode.parentNode.removeChild(oTrNode);
40                 }
41             
42     </script>
43     <table id="fileid">
44         <tr>
45             <td><a href="javascript:void(0)" onclick="addFile()">添加附件</a></td>
46         </tr>
47         <!--
48         <tr>
49             <td><input type="file" /></td>
50             <td><a href="javascript:void(0)">删除附件</a></td>
51         </tr>-->
52     </table>
53     
54     
55 </body>
56 </html>
View Code

 

转载于:https://www.cnblogs.com/aineko/p/3784832.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值