The example in this article describes how jQuery dynamically adds and deletes form upload elements. Share it with everyone for your reference, the details are as follows:
The screenshot of the running effect is as follows:
Click here to view the online demonstration .
The specific code is as follows:
<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>
Click here for the complete example codeDownload from this site.
I hope this article will be helpful to everyone in jQuery programming.