日期:2014-05-16 浏览次数:20320 次
<!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=utf-8" />
<title>判断</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
.div1{width:200px; height:30px; background:#069; margin-top:20px;}
.div2{width:50px;height:30px; background:#00BCF3;line-height:30px;text-align:center;cursor:pointer;}
</style>
</head>
<body>
<div style="margin:100px 500px;">
<input id="v_input" type="text" value="1" /><br />
<div id="zj_div">
<div class="div1">
<a style="float:right;" href="javascript:void(0)" onclick="del(this)">删除</a>
</div>
</div>
<div id="btn_div" class="div2">增加</div>
</div>
</body>
<script type="text/javascript">
var i= 0,oTab;
window.onload=function(){
oTab = document.getElementById('zj_div');
document.getElementById('btn_div').onclick=function(){
oTab.appendChild(oTab.children[0].cloneNode(true));
i++;
}
};
function del(obj){
i&&oTab.removeChild(obj.parentNode)&&i--;
}
</script>
</html>