Last active
July 17, 2018 08:39
-
-
Save davidsaccavino/c438be1f79a2d04d4e5c8a00809f7bf6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script> | |
let editValueState = false; | |
function editValue(){ | |
if(editValueState == false) | |
{ | |
editValueState = true; | |
document.getElementById("editbtn").innerHTML = "editing"; | |
} | |
else | |
{ | |
editValueState = false; | |
document.getElementById("editbtn").innerHTML = "edit"; | |
} | |
}; | |
function submitButton(){ | |
let para = document.createElement("p"); | |
let text = document.createTextNode(document.getElementById("inputbox").value); | |
para.appendChild(text); | |
document.body.appendChild(para); | |
para.onclick = () => { | |
if(editValueState == false) | |
{ | |
para.parentNode.removeChild(para) | |
} | |
else | |
{ | |
para.innerHTML = prompt("Please enter the edited task.", "Edited Task"); | |
} | |
}; | |
}; | |
</script> | |
<h1>Todo List</h1> | |
</head> | |
<body> | |
<input id="inputbox" type="text" value="New Task"> | |
<button onClick="submitButton()">Submit</button> | |
<button id="editbtn" onClick="editValue()">edit</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment