Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

creat checkbox and append it to a list js

function addItem(){
    var ul = document.getElementById('ul'); //ul
    var li = document.createElement('li');//li

    var checkbox = document.createElement('input');
        checkbox.type = "checkbox";
        checkbox.value = 1;
        checkbox.name = "todo[]";

    li.appendChild(checkbox);

    var text = document.getElementById('texto');
    li.appendChild(document.createTextNode(text.value));
    ul.appendChild(li); 
}

var button = document.getElementById('btn');
button.onclick = addItem;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #creat #checkbox #append #list #js
ADD COMMENT
Topic
Name
3+6 =