Advertisement
PadmaJS

Untitled

Jul 14th, 2020
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>TODO List</title>
  5. </head>
  6. <body>
  7. <h1>To-Do List</h1>
  8. <input placeholder="Type Here" id="input">
  9. <button onclick="add()">Add</button>
  10.  
  11. <div id="items"><ol>
  12. <li id="item1"></li><button id="check1" onclick="clear1()">Done</button>
  13. <li id="item2"></li><button id="check2" onclick="clear2()">Done</button>
  14. <li id="item3"></li><button id="check3" onclick="clear3()">Done</button>
  15. <li id="item4"></li><button id="check4" onclick="clear4()">Done</button>
  16. <li id="item5"></li><button id="check5" onclick="clear5()">Done</button>
  17. </ol></div>
  18. <script type="text/javascript">
  19. var item1 = document.getElementById("item1");
  20. var item2 = document.getElementById("item2");
  21. var item3 = document.getElementById("item3");
  22. var item4 = document.getElementById("item4");
  23. var item5 = document.getElementById("item5");
  24. document.getElementById("check1").style.display = "none";
  25. document.getElementById("check2").style.display = "none";
  26. document.getElementById("check3").style.display = "none";
  27. document.getElementById("check4").style.display = "none";
  28. document.getElementById("check5").style.display = "none";
  29. function add(){
  30. var input = document.getElementById("input").value;
  31. if(item1.innerText == "") {
  32. item1.innerText = input;
  33. document.getElementById("check1").style.display = "block";
  34. } else if(item2.innerText == "") {
  35. item2.innerText = input;
  36. document.getElementById("check2").style.display = "block";
  37. } else if(item3.innerText == "") {
  38. item3.innerText = input;
  39. document.getElementById("check3").style.display = "block";
  40. } else if(item4.innerText == "") {
  41. item4.innerText = input;
  42. document.getElementById("check4").style.display = "block";
  43. } else if(item5.innerText == "") {
  44. item5.innerText = input;
  45. document.getElementById("check5").style.display = "block";
  46. }
  47. }
  48. function clear1(){
  49. item1.innerText = "";
  50. document.getElementById("check1").style.display = "none";
  51. }
  52. function clear2(){
  53. item2.innerText = "";
  54. document.getElementById("check2").style.display = "none";
  55. }
  56. function clear3(){
  57. item3.innerText = "";
  58. document.getElementById("check3").style.display = "none";
  59. }
  60. function clear4(){
  61. item4.innerText = "";
  62. document.getElementById("check4").style.display = "none";
  63. }
  64. function clear5(){
  65. item5.innerText = "";
  66. document.getElementById("check5").style.display = "none";
  67. }
  68. </script>
  69. </body>
  70. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement