易网时代-编程资源站
Welcome
微信登录
编程资源
图片资源库
蚂蚁家优选
PDF转换器
软件资源
软件开发
、
小程序制作
、
系统集成与运维
、
空间租用
、
硬件开发
、
视频监控
、
技术咨询与支持
——联系电话:0311-88999002/88999003
首页
/
操作系统
/
Linux
/
JQuery实现动态增加和删除文本框
JQuery实现动态增加和删除文本框
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<head>
<meta
http-equiv
=
"Content-Type"
content
=
"text/html; charset=gbk"
/>
<title>
Untitled Document
</title>
<mce:script
type
=
"text/javascript"
src
=
"jquery-1.4.2.js"
mce_src
=
"jquery-1.4.2.js"
></mce:script>
<mce:script
type
=
"text/javascript"
>
<!--
$(function(){
var
i
=
2
;
$("#addTextImput").click(function(){
if(i
<
100
) {
$("#main").append("
<div><input
type
=
"text"
name
=
"text"
+ i + ""
/><input
type
=
"button"
id
=
"del-text"
value
=
"删除"
></div>
");
i++;
} else {
alert("最多加100个");
}
});
$(".del-text").live("click",function(){
$(this).parent().remove();
i--;
});
$("#del-text").live("click",function(){
$(this).parent().remove();
i--;
});
});
// --
></mce:script>
</head>
<body>
<div
id
=
"main"
>
<div><input
type
=
"text"
name
=
"text1"
/></div>
</div>
<input
type
=
"button"
id
=
"addTextImput"
value
=
"添加"
/>
</body>
</html>
收藏该网址
版权所有©石家庄振强科技有限公司2024
冀ICP备08103738号-5
网站地图