<div class="codetitle"> <span><a style="CURSOR: pointer" data="78637" class="copybut" id="copybut78637" onclick="doCopy('code78637')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code78637"> <br><html xmlns="http://www.w3.org /1999/xhtml"> <br><head runat="server"> <br><title>Jquery动态控件</title> <br><script src="jquery-1.4.2.js" type="text/javascript"></script> <br><script type="text/javascript"> <br>$(function() { <br>var i = 2; <br>$('#addText').click(function() { <br>if (i < 9) { <BR>$( '#main').append('<div><input type="text" name="text" i ""/> <br> <a href="# " 클래스="델-텍스트" >del</a></div>'); <br>i ; <br>} else { <br>alert("最多只能添加8个") <br>} <br>}) ; <br>$('.del-text').live('click',function(){ <br>$(this).parent().remove(); <br>i--; <br> }) <br>}); <br></script> <br></head> <br><본문> <br><div id="main"> <br><div> <br><input type="text" name="text1" /> <br></div> <br></div> <br><a id="addText" href="#">添加文本框</a> <br></body> <br></html> </div>