jquery 動(dòng)態(tài)增加,減少input表單的簡(jiǎn)單方法(必看)
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>
以上就是小編為大家?guī)?lái)的jquery 動(dòng)態(tài)增加,減少input表單的簡(jiǎn)單方法(必看)全部?jī)?nèi)容了,希望大家多多支持腳本之家~
- input 輸入框獲得/失去焦點(diǎn)時(shí)隱藏/顯示文字(jquery版)
- jquery顯示隱藏input對(duì)象
- jQuery實(shí)現(xiàn)表單input中提示文字value隨鼠標(biāo)焦點(diǎn)移進(jìn)移出而顯示或隱藏的代碼
- jQuery 隱藏和顯示 input 默認(rèn)值示例
- jQuery通過(guò)改變input的type屬性實(shí)現(xiàn)密碼顯示隱藏切換功能
- jquery form 隱藏的input 選擇
- jQuery響應(yīng)鼠標(biāo)事件并隱藏與顯示input默認(rèn)值
- jQuery解決input超多的表單提交
- jquery獲取form表單input元素值的簡(jiǎn)單實(shí)例
- jQuery獲取及設(shè)置表單input各種類型值的方法小結(jié)
- jQuery實(shí)現(xiàn)提交表單時(shí)不提交隱藏div中input的方法
相關(guān)文章
jQuery數(shù)據(jù)檢索中根據(jù)關(guān)鍵字快速定位GridView指定行的實(shí)現(xiàn)方法
這篇文章主要介紹了jQuery數(shù)據(jù)檢索中根據(jù)關(guān)鍵字快速定位GridView指定行的實(shí)現(xiàn)方法,涉及jQuery結(jié)合asp.net操作頁(yè)面元素及樣式的相關(guān)技巧,需要的朋友可以參考下2016-06-06
jQuery實(shí)現(xiàn)的倒計(jì)時(shí)效果實(shí)例小結(jié)
這篇文章主要介紹了jQuery實(shí)現(xiàn)的倒計(jì)時(shí)效果,結(jié)合實(shí)例形式總結(jié)分析了jQuery針對(duì)日期與時(shí)間的運(yùn)算實(shí)現(xiàn)倒計(jì)時(shí)功能的相關(guān)技巧,需要的朋友可以參考下2016-04-04
細(xì)說(shuō)瀏覽器特性檢測(cè)(1)-jQuery1.4添加部分
瀏覽器特性檢測(cè)即通過(guò)探測(cè)對(duì)象是否擁有某個(gè)屬性或者函數(shù),或者通過(guò)其他的編碼探測(cè)方式,來(lái)決定其是否支持某一功能、特性。2010-11-11
BootStrap glyphicon圖標(biāo)無(wú)法顯示的解決方法
如果不注意bootstrap引入css和fonts的規(guī)范,則可能會(huì)導(dǎo)致bootstrap 在顯示glyphicon圖標(biāo)時(shí)無(wú)法正常顯示,顯示為方框。該怎么解決呢?下面小編給大家解答下2016-09-09
jQuery Raty星級(jí)評(píng)分插件使用方法實(shí)例分析
這篇文章主要介紹了jQuery Raty星級(jí)評(píng)分插件使用方法,結(jié)合實(shí)例形式分析了jquery Raty星級(jí)評(píng)分插件的下載、調(diào)用、基本屬性及相關(guān)使用技巧,需要的朋友可以參考下2019-11-11
快速解決jquery.touchSwipe左右滑動(dòng)和垂直滾動(dòng)條沖突
這篇文章主要介紹了快速解決jquery.touchSwipe左右滑動(dòng)和垂直滾動(dòng)條沖突問(wèn)題,感興趣的小伙伴們可以參考一下2016-04-04

