avascript create list group dynamically onclick javacscript

Solutions on MaxInterview for avascript create list group dynamically onclick javacscript by the best coders in the world

showing results for - "avascript create list group dynamically onclick javacscript"
Sohan
06 Mar 2020
1function addItem(){
2    var ul = document.getElementById("dynamic-list");
3    var candidate = document.getElementById("candidate");
4    var li = document.createElement("li");
5    li.setAttribute('id',candidate.value);
6    li.appendChild(document.createTextNode(candidate.value));
7    ul.appendChild(li);
8}
9
10function removeItem(){
11    var ul = document.getElementById("dynamic-list");
12    var candidate = document.getElementById("candidate");
13    var item = document.getElementById(candidate.value);
14    ul.removeChild(item);
15}