JavaScript implementation love you in FF IE are effective to add a project _ form effects

Source: Internet
Author: User
IE is not very good, in IE setattribute only to recognize some static properties, and like the onclick event is invalid, to use the Attchevent method
<ptml> <pead> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/> <title> Untitled document </title> </pead> <script type=" Text/javascript "> var elemen tcount=0; function Mycreateelement (element,tag) {elementcount++; var parentelement=element; var Count=elementcount; var childelement=document.createelement (tag); SetProperty (childelement, "type", "text"); SetProperty (childelement, "id", "input" + Elementcount) var delelement=document.createelement ("input"); SetProperty (delelement, "type", "button"); SetProperty (delelement, "value", "delete"); SetProperty (delelement, "id", "Delbutton" + elementcount) if (navigator.appname== "Microsoft Internet Explorer") del Element.attachevent ("onclick", function () {del (count)}) Else SetProperty (delelement, "onclick", "del" + Elementcoun T + ")"); var wrap=document.createelement (' div ') setProperty (wrap, "id", "div" + elementcount) wrap.aPpendchild (childelement); Wrap.appendchild (delelement); Parentelement.appendchild (Wrap)} function SetProperty (element,tag,property) {var element1=element; Element1.setattribute (Tag,property); } function del (elementCount1) {var Parentnode=document.getelementbyid ("Mycontent"); var Divnode=document.getelementbyid ("div" +elementcount1); Parentnode.removechild (Divnode); } </script> <body> <div id= "mycontent" > </div> <input type= "button" value= "Add" onclick= "my CreateElement (document.getElementById (' mycontent '), ' input ') ' > </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Related Article

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.