ホームページ  >  記事  >  ウェブフロントエンド  >  jQuery は input type=file 実装コードを動的に追加します

jQuery は input type=file 実装コードを動的に追加します

高洛峰
高洛峰オリジナル
2017-02-11 17:16:351396ブラウズ

<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>

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

input type=file の jQuery 動的追加実装コードの詳細については、PHP 中国語 Web サイトの関連記事に注目してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。