Add, remove HTML nodes & upload picture previews _javascript tips

Source: Internet
Author: User
1. Add and remove HTML nodes
2. Upload Picture preview
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "lang=" gb2312 "> <pead> <title > Add, delete HTML node & upload picture preview </title> <meta http-equiv= "Content-type" content= text/html; charset=gb2312 "/> <meta name=" author "content=" Maple Rock, http://www.cnlei.com "> <meta name=" keywords "content=" "/> <meta name=" description "content=" "/> <script type=" Text/javascript "> <!--function AddChild (s Pid) {var otextnode = document.getElementById ("Tplnode"). getElementsByTagName ("li") [0]; var oclone = Otextnode.clonenode (Otextnode); var P=document.getelementbyid (SPid); P.appendchild (Oclone); function Delchild (o,spid) {var otextnode = O.parentnode; var P=document.getelementbyid (SPid); P.removechild (Otextnode); The function previewimg (o,spid) {document.getElementById (sPid). Src=o.value; }--> </script> </pead> <body> <ul id= "Tplnode" > <li><input type= "File" name= "" value= "" size= "" onchange= "Previ Ewimg (This, ' previmg '); "/>  Delete </li> </ul> <ul id=" Upfiles "> <li><input type=" File " Name= "" value= "" size= "" onchange= "previewimg (This, ' previmg ');"/>  Delete </li> </ul> <p> Add Accessories </p> <p> picture preview:<br></p> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.