Reputation:
Here I am getting values from sqlite db,binding those values in javascript and showing it on html by calling id of that particular .In this process I reuired to put checkbox.I created it in javascript only not in html. so now i required to check the checkbox in dynamically created javascript. here I am pasting my code. Thanks in advance for your valuable suggestions.
$('#lightsList').append('<li style="background:#666666">'+
'<img src="../images/' + light.ledLightImage + '" class="ui-li-thumb" style="margin-left: 10px; margin-top:2px;"/>' +
'<form id="checkbox" style="padding-top:18px; color:#ffffff">'+
'<input type="checkbox" name="Tick" value="Tick" class="regular-checkbox" onclick="checked()"/><br>Tick'+
'</form>' +
'<p class="line1">' + light.ledLightName + '</p>' +
'</li>'+
'<li style="display:none;">'+light.ledWattage+'</li>');
Upvotes: 0
Views: 617
Reputation: 40639
You need to use on() for event delegation like,
$('#lightsList').on('click', '.regular-checkbox', function() {
checked();// call your function checked here
});
Upvotes: 1
Reputation: 6612
Try this:
$(document).on('change', '.regular-checkbox', function() {
// event handler
});
Upvotes: 0