- jquery dynamic Add input type=file file upload domain, when users need to upload multiple files through the Web page, the dynamic addition of file domain is particularly important, this feature introduced jquery, compatibility is also good, there is no limit the number of file fields, So you can generate unlimited file domains until your needs are met.
<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=gb2312" /><title>Contact Angle Measuring instrument</title><Scripttype= "Text/javascript"src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></Script> </Head><Body> <formAction=""Method= "POST"enctype= "Multipart/form-data"> <label>Please select the uploaded picture</label> <ahref= "javascript:addimg ()" >Add image</a> <Divclass= "MDiv"ID= "MDiv"> <Divclass= "Iptdiv" > <inputtype= "File"name= "img[]"class= "IPT" /><ahref="#"name= "Rmlink">X</a> </Div> </Div> <inputtype= "Submit"name= "Submit"value= "Upload picture" /> </form> <Scripttype= "Text/javascript" >$ (document). Ready (function() {Bindlistener ();});//used to bind events (use Unbind to avoid duplicate bindings)functionBindlistener () {$ ("A[name=rmlink]"). Unbind (). Click (function(){ $( This). Parent (). remove (); })}functionaddimg () {$ ("#mdiv"). Append ('<div class= "Iptdiv" ><input type= "file" name= "img[" "class=" IPT "/><a href=" # "Name=" Rmlink "> X </a></div>');//to add an event listener for a new element node//Download Jb51.netBindlistener ();} </Script></Body></HTML>