×

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

作者:Terry2017.02.06来源:Web前端之家浏览:10065评论:0
关键词:JQueryJS

复制代码 代码如下:

<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/

您的支持是我们创作的动力!
温馨提示:本文作者系Terry ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://jiangweishan.com/article/svg1486310400730.html

网友评论文明上网理性发言已有0人参与

发表评论: