Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add checkbox dynamically in javascript

$(document).ready(function() {
  $('#submit').click(function() {
    var list = ['Car', 'Bike', 'Scooter'];
    for (var value of list) {
      $('#container')
        .append(`<input type="checkbox" id="${value}" name="interest" value="${value}">`)
        .append(`<label for="${value}">${value}</label></div>`)
        .append(`<br>`);
    }
  })
});
Source by www.techiedelight.com #
 
PREVIOUS NEXT
Tagged: #add #checkbox #dynamically #javascript
ADD COMMENT
Topic
Name
7+9 =