Home > Web Front-end > JS Tutorial > body text

jQuery dynamically adds input type=file implementation code

高洛峰
Release: 2017-02-11 17:16:35
Original
1452 people have browsed 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>
Copy after login

Core jquery code

//添加一行<tr> 
function add() { 
var content = "<tr><td>"; 
content += "<input type=&#39;file&#39; name=&#39;file&#39;><input type=&#39;button&#39; value=&#39;Remove&#39; onclick=&#39;remove(this)&#39;>"; 
content += "</td></tr>" 
$("#fileForm").append(content); 
} 
//删除当前行<tr> 
function remove(obj) { 
$(obj).parent().parent().remove(); 
}
Copy after login

For more jQuery dynamically added input type=file implementation code related articles, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template