您的位置:首页 > Web前端 > JavaScript

js代码实现填写简历时“添加项目经历”功能

2012-12-06 13:56 691 查看

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script>
var index=0;
function addedu(){
//alert(index);

var edu=document.getElementById("education");
var current = document.getElementById("current_edu");
current.removeAttribute("id");
//var count = current.childNodes.length;
index++;
var button = document.getElementById("add_but");
var new_button = button.cloneNode();
//alert(index+":"+count);
current.removeChild(button);
//var another = first.cloneNode();
var another = document.createElement("div");
//var child_text1 = document.createTextNode("");
var child_time = document.createElement("input");
var time_text = document.createTextNode("时间");
child_time.setAttribute("type","text");
child_time.setAttribute("name","time"+index);

var child_name=document.createElement("input");
var name_text = document.createTextNode("学校");
child_name.setAttribute("type","text");
child_name.setAttribute("name","edu"+index);

var child_br = document.createElement("br");
another.appendChild(time_text);
another.appendChild(child_time);
another.appendChild(name_text);
another.appendChild(child_name);
another.appendChild(new_button);
another.appendChild(child_br);
another.setAttribute("id","current_edu");
edu.appendChild(another);

}
</script>
</head>

<body>
<div id="education">
<div id="current_edu">
时间<input type="text" name="time0"/>学校<input type="text" name="edu0"/>
<input type="button" value="+" id="add_but" onclick="addedu();"/>
<br/>
</div>
</div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐