jquery dynamic Add input type=file file upload domain

Source: Internet
Author: User
Tags event listener

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.