無限欄位
這是我做的一個小範例給大家參考,總之 我愛 JQUERY
<script type="text/javascript" src="/js/jquery.js"></script> <script type="text/javascript" > function delthis($input) { //alert("01"); $("#"+$input).remove(); } function addnew() { _tmpcount=$("#tmpcount").html(); _nowhtml=$("#addsayadd").html(); _tmphtml='<div id="addsay'+_tmpcount+ '" ><br><input maxlength="10" size="10" name="addsay[]"> <textarea cols="10" rows="2" name="addsayc[]"></textarea> <input value="delthis" type="button" onclick="delthis(\'addsay'+_tmpcount+'\')" ></div>'; $("#addsayadd").add(_tmphtml).appendTo($("#addsayadd"));; $(tmpcount).html(_tmpcount++); } </script> <div id="tmpcount">1</div> <input type="button" value="addnew" onclick="addnew()"> <div id="addsay" ><br> <input maxlength="10" size="10" name="addsay[]"> <textarea cols="10" rows="2" name="addsayc[]"></textarea></div> <div id="addsayadd" ></div>
留言板
歡迎留下建議與分享!希望一起交流!感恩!