()
| 1 | // Function called while clicking add button |
| 2 | function add_item() { |
| 3 | |
| 4 | // Getting box and ul by selecting id; |
| 5 | let item = document.getElementById("box"); |
| 6 | let list_item = document.getElementById("list_item"); |
| 7 | if(item.value != ""){ |
| 8 | |
| 9 | // Creating element and adding value to it |
| 10 | let make_li = document.createElement("LI"); |
| 11 | make_li.appendChild(document.createTextNode(item.value)); |
| 12 | |
| 13 | // Adding li to ul |
| 14 | list_item.appendChild(make_li); |
| 15 | |
| 16 | // Reset the value of box |
| 17 | item.value="" |
| 18 | |
| 19 | // Delete a li item on click |
| 20 | make_li.onclick = function(){ |
| 21 | this.parentNode.removeChild(this); |
| 22 | } |
| 23 | |
| 24 | } |
| 25 | else{ |
| 26 | |
| 27 | // Alert msg when value of box is "" empty. |
| 28 | alert("Please add an item in To-do list"); |
| 29 | } |
| 30 | |
| 31 | } |
nothing calls this directly
no outgoing calls
no test coverage detected