emplist
by Kumaresan S
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input id="new-profile" type="text">
<button id="btn">Add</button>
<ul id="hold">
</ul>
<ul id="processing">
</ul>
</body>
</html>
JavaScript
var profile = document.getElementById("new-profile");
var addBtn = document.getElementById("btn");
var profileHold = document.getElementById("hold");
var profileProcessing = document.getElementById("processing");
// hold list
var createHoldListElements = function(value){
var empList = document.createElement("li");
var profileName = document.createElement("input");
var editBtn = document.createElement("button");
profileName.type = "text";
editBtn.innerText="delete";
profileName.value = value;
empList.appendChild(profileName);
empList.appendChild(editBtn);
return empList;
console.log("Add task...");
}
var addProfile = function(){
var empList = createHoldListElements(profile.value);
//alert("test");
profileHold.appendChild(empList);
}
var deleteProfile = function(){
var ul = empList.parentNode;
ul.removeChild(empList);
}
addBtn.addEventListener("click", addProfile);
editBtn.addEventListener("click", deleteProfile);