<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> <br> <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="#" class="del-text">del</script> </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> <br> <br> <br><div id="main"> <br><div> <br><input type="text" name="text1"> <br> </div> <br> </div> <br><a id="addText" href="#">添加文本框</a> <br> <br> <br> <br>先把前台的整理出来,项目临时有需求,先去忙了,稍后发后台取值的方法...