Home  >  Article  >  Web Front-end  >  jQuery动态添加及删除表单上传元素的方法(附demo源码下载)_jquery

jQuery动态添加及删除表单上传元素的方法(附demo源码下载)_jquery

WBOY
WBOYOriginal
2016-05-16 15:19:541318browse

本文实例讲述了jQuery动态添加及删除表单上传元素的方法。分享给大家供大家参考,具体如下:

运行效果截图如下:

点击此处查看在线演示效果

具体代码如下:

<html>
<head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
 $(":input[type=button][value=more]").bind("click",function(){
 var $br = $("<br />");
 var $file = $("<input type='file' name='name1' />");
 var $button = $("<input type='button' value='delete'>");
 $(this).after($file).after($button).after($br);
 $button.bind("click",function(){
  $br.remove();
  $file.remove();
  $button.remove();
 })
 })
});
</script>
</head>
<body>
<input type="file" name="file1" /><input type="button" value="more" />
</body>
</html>

完整实例代码点击此处本站下载

希望本文所述对大家jQuery程序设计有所帮助。

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