本文實例為大家分享了jQuery實現(xiàn)動態(tài)添加和刪除input框的具體代碼,供大家參考,具體內(nèi)容如下
成都創(chuàng)新互聯(lián)專注于鄭州網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供鄭州營銷型網(wǎng)站建設(shè),鄭州網(wǎng)站制作、鄭州網(wǎng)頁設(shè)計、鄭州網(wǎng)站官網(wǎng)定制、微信小程序定制開發(fā)服務(wù),打造鄭州網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供鄭州網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>選項</title> <script type="text/javascript" src="js/jquery-1.8.3.js"></script> <script> $(function(){ // 添加選項 $("#opbtn").click(function(){ if($("#opts>li").size() < 6){// 最多添加6個選項 $("#opts").append("<li><input /></li>"); }else{// 提示選項個數(shù)已經(jīng)達到最大 $("#optips").html("選項個數(shù)已經(jīng)達到最大,不能再添加!"); $("#optips").css({"color":"red"}); } }); // 刪除選項 $("#delbtn").click(function(){ if($("#opts>li").size() <= 0){ $("#optips").html("已經(jīng)沒有選項可以刪除了!"); $("#optips").css({"color":"red"}); } else{ // 刪除選項,每次刪除最后一個 $("#opts>li").last().remove(); } }); }); </script> <style> *{ margin: 0px; padding: 0px; } #dv{ width: 100px; height: 100px; background-color: yellow; margin: 0px auto 0px; } </style> </head> <body> <div > <input id="opbtn" type="button" value="添加選項"/> <input id="delbtn" type="button" value="刪除選項"/> <input id="wrapbtn" type="button" value="包圍DIV"/> <ol id="opts" type="A"></ol> <!-- 提示語 --> <span id="optips"></span> </div> </body> </html>
以上所述是小編給大家介紹的jQuery實現(xiàn)動態(tài)添加和刪除input框,詳解整合,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對創(chuàng)新互聯(lián)網(wǎng)站的支持!
網(wǎng)站題目:jQuery實現(xiàn)動態(tài)添加和刪除input框代碼實例
網(wǎng)頁鏈接:http://chinadenli.net/article34/joihpe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、Google、ChatGPT、全網(wǎng)營銷推廣、軟件開發(fā)、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)