联系我们
简单又实用的WordPress网站制作教学
当前位置:网站首页 > 网页前端技术 > 正文

jQuery动态添加 input type=file的实现代码 - Web前端

作者:98wpeu发布时间:2026-07-09分类:网页前端技术浏览:2


导读:复制代码代码如下:<FORMid="fileform"action=""method="post"enctype="multipart/form-data">...

复制代码 代码如下:
<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/

标签:代码动态Webfiletypeinput


网页前端技术排行
最近发表
网站分类
标签列表