欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript動(dòng)態(tài)數(shù)量的文件上傳控件

 更新時(shí)間:2016年11月18日 14:08:53   作者:li_magic  
本文給大家分享一段js代碼關(guān)于動(dòng)態(tài)數(shù)量的文件上傳控件,代碼簡(jiǎn)單易懂,非常不錯(cuò)具有參考借鑒價(jià)值,感興趣的朋友一起看看

js動(dòng)態(tài)數(shù)量的文件上傳控件實(shí)現(xiàn)代碼如下所述:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>動(dòng)態(tài)數(shù)量的文件上傳</title>
<script type="text/javascript" src="jquery-2.2.0.min.js">
</script><script type="text/javascript">
$(function(){
var i=2;
$("#addFile").click(function(){
$(this).parent().parent().before("<tr class='file'><td>File"
+i+":</td><td><input type='file' name='file"
+i+"'/></td></tr>"
+"<tr class='desc'><td>Desc"
+i+":</td><td><input type='text' name='desc"
+i+"'/><button id='delete"
+i+"'>刪除</button></td></tr>");
i++;
//刪除
$("#delete"+(i-1)).click(function(){
var $tr=$(this).parent().parent();
$tr.prev("tr").remove();
$tr.remove();
//對(duì)i排序
$(".file").each(function(index){
var n=index+1;
$(this).find("td:first").text("File"+n);
$(this).find("td:last input").attr("name","file"+n);
});
$(".desc").each(function(index){
var n=index+1;
$(this).find("td:first").text("Desc"+n);
$(this).find("td:last input").attr("name","desc"+n);
});
});
});
});
</script>
</head>
<body>
<table>
<tr class="file">
<td>File1:</td>
<td><input type="file" name="file1"/></td>
</tr>
<tr class="desc">
<td>Desc1:</td>
<td><input type="text" name="desc1"/></td>
</tr>
<tr>
<td><input type="submit" id="submit" value="上傳"/></td>
<td><button id="addFile">增加</button></td>
</tr>
</table>
</body>
</html>

好了,代碼到此結(jié)束了,希望對(duì)大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的,在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論