Search
 
SCRIPT & CODE EXAMPLE
 

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;
Comment

PREVIOUS NEXT
Code Example
Javascript :: compass in react js 
Javascript :: Access nested objects and arrays using string path 
Javascript :: Angular : pass data to component loaded via route 
Javascript :: Literal string with a variable inserted 
Javascript :: bootstrapmaterialdatepicker get selected value on changes 
Javascript :: eleventy stringify 
Javascript :: how to set particle js not hovering over contents 
Javascript :: Half or Left Triangle Pattern in JavaScript 
Javascript :: Fibonacci perticular position in javascript 
Javascript :: angular number pipe to four decimals 
Javascript :: javascript to reload django partial 
Javascript :: how to add fcc cdn to local react projcet 
Javascript :: react date component with word month 
Javascript :: js what does the vertical line symbol do 
Javascript :: nodejs RPL 
Javascript :: random bigint javascript 
Javascript :: online validator json schema 2020-12/schema 
Javascript :: jquery hide elevateZoom 
Javascript :: waitfordisplayed 
Javascript :: Play Gif or Video On hover Jquery 
Javascript :: how to send varible to another page in nuxt.js 
Javascript :: if else condition in angular if user enter string value in input integer 
Javascript :: using fetch hook 
Javascript :: on scroll image blur jquery 
Javascript :: foreach doesnt return 
Javascript :: jwt sign options 
Javascript :: wakatime cli installation via npm 
Javascript :: get position of an object inside a container phaser 3 
Javascript :: koa wildcard route 
Javascript :: on change jquery kendo switch 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =