网络编程 
首页 > 网络编程 > 浏览文章

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

(编辑:jimmy 日期: 2025/12/26 浏览:3 次 )

复制代码 代码如下:
<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操作select的实例代码
下一篇:jQuery 翻牌或百叶窗效果(内容三秒自动切换)
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap