欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實(shí)現(xiàn)動(dòng)態(tài)添加和刪除input框代碼實(shí)例

 更新時(shí)間:2019年03月29日 11:58:09   作者:賴木子  
這篇文章主要介紹了jQuery實(shí)現(xiàn)動(dòng)態(tài)添加和刪除input框,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

本文實(shí)例為大家分享了jQuery實(shí)現(xiàn)動(dòng)態(tài)添加和刪除input框的具體代碼,供大家參考,具體內(nèi)容如下

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>選項(xiàng)</title>
 
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
 
<script>
	$(function(){
		// 添加選項(xiàng)
		$("#opbtn").click(function(){
			if($("#opts>li").size() < 6){// 最多添加6個(gè)選項(xiàng)
				$("#opts").append("<li><input /></li>");
			}else{// 提示選項(xiàng)個(gè)數(shù)已經(jīng)達(dá)到最大
				$("#optips").html("選項(xiàng)個(gè)數(shù)已經(jīng)達(dá)到最大,不能再添加!");
				$("#optips").css({"color":"red"});
			}
			
		});
		
		// 刪除選項(xiàng)
		$("#delbtn").click(function(){
			if($("#opts>li").size() <= 0){
				$("#optips").html("已經(jīng)沒有選項(xiàng)可以刪除了!");
				$("#optips").css({"color":"red"});
			} else{
				// 刪除選項(xiàng),每次刪除最后一個(gè)
				$("#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 style="margin: 50px;">
		<input id="opbtn" type="button" value="添加選項(xiàng)"/>
		<input id="delbtn" type="button" value="刪除選項(xiàng)"/>
		<input id="wrapbtn" type="button" value="包圍DIV"/>
		<ol id="opts" type="A"></ol>
		
		<!-- 提示語(yǔ) -->
		<span id="optips"></span>
	</div>
	
	
</body>
</html>
 

以上所述是小編給大家介紹的jQuery實(shí)現(xiàn)動(dòng)態(tài)添加和刪除input框,詳解整合,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論