当前位置:Gxlcms > JavaScript > jQuery动态添加inputtype=file的实现代码

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

时间:2021-07-01 10:21:17 帮助过:5人阅读

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

更多jQuery动态添加 input type=file的实现代码相关文章请关注PHP中文网!

人气教程排行