jQuery动态添加 input type=file的实现代码

2019-12-24,,,,

复制代码 代码如下:
<form id="fileForm" action="" method="post" enctype="multipart/form-data">
<tr>
<td>
<input type="file" name="file"><input type="button" id="addButon" value="Add" onclick="add()">
</td>
</tr>
</form>

核心jquery代码
复制代码 代码如下:
//添加一行<tr>
function add() {
var content = "<tr><td>";
content += "<input type='file' name='file'><input type='button' value='Remove' onclick='remove(this)'>";
content += "</td></tr>"
$("#fileForm").append(content);
}
//删除当前行<tr>
function remove(obj) {
$(obj).parent().parent().remove();
}

北冥有鱼整理的在线演示:http://demo.jb51.net/jquery/juqery_input/

您可能感兴趣的文章:

  • jquery获取input type=text中的值的各种方式(总结)
  • jquery对所有input type=text的控件赋值实现方法
  • jQuery动态添加<input type="file">
  • jQuery操作input type=radio的实现代码
  • jQuery操作 input type=checkbox的实现代码
  • jQuery通过改变input的type属性实现密码显示隐藏切换功能
  • jquery 动态增加input

《jQuery动态添加 input type=file的实现代码.doc》

下载本文的Word格式文档,以方便收藏与打印。