jquery 动态增加,减少input表单的简单方法(必看)
2016年11月22日
html代码如下
<html> <tr><button style="margin-left:10px" class="add_field_button btn">Add</button></tr> <tbody class="input_fields_wrap"></tbody> </html>js代码如下
<script> var max_fields = 5; //maximum input boxes allowed var wrapper = $(".input_fields_wrap"); //Fields wrapper var add_button =(".add_field_button"); //Add button ID var x = 1; //initlal text box count $(add_button).click(function(e){ //on add input button click e.preventDefault(); if(x < max_fields){ //max input box allowed x++; //text box increment $(wrapper).append('<tr style=""><td></td><td><button class="remove_field btn">Del</button></td></tr>'); //add input box } }); $(wrapper).on("click",".remove_field", function(e){ //user click on remove text e.preventDefault(); $(this).closest('tr').remove(); x--; }) </script>以上就是小编为大家带来的jquery 动态增加,减少input表单的简单方法(必看)全部内容了,希望大家多多支持~
相关阅读
-
工商银行喜结良缘金条30克价格今天多少一克(2024年05月03日)
-
工商银行筑梦中华金条100克价格今天多少一克(2024年05月03日)
-
2024版熊猫纪念币150克精制金币现在市场价是多少(2024年05月03日)
-
2024版3克熊猫金币价格(2024年05月03日)
-
周生生铂金多少钱一克(2024年05月03日)参考价格
-
北京菜百铂金多少钱一克(2024年05月03日)参考价格
-
北京菜百黄金价格今天多少一克(2024年05月03日)
-
上海老庙铂金多少钱一克(2024年05月03日)参考价格
-
黄金9995价格多少钱一克(2024年05月03日)
-
周大福黄金价格今天多少一克(2024年05月03日)