当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jQuery动态添加 input type=file的实现代码

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

2018年10月30日  | 移动技术网IT编程  | 我要评论

代码如下:

<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();
}

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网