ตัวอย่างโค้ด
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <style type= "text/css" > .inp_email{ clear:both;float:left; } </style> <form id= "form1" name= "form1" method= "post" action= "" > <div id= "mailfriend" >Your friend email:</div> <input name= "email[]" class = "inp_email" type= "text" id= "email[]" size= "35" /> <br style= "clear:both;float:left;" /> <input type= "submit" name= "Submit5" value= "บันทัก" /> <input type= "button" id= "addmail" name= "Button2" value= "เพิ่มอีเมลล์" /> </form> <script language= "javascript" > $( function (){ $( "#addmail" ).click( function (){ // เงื่อนไขการคลิกสำหรับทดสอบ $( "#mailfriend" ).after( "<input name=email[] class=inp_email type=text size=35 /><input class=bt_remove type=button value=ลบ />" ); }); $(document.body).on( "click" , ".bt_remove" , function (){ $(this).prev( "input" ).remove(); this.remove(); }); }); </script> |
ตัวอยย่างผลลัพธิ์