我正在调用function testing(id)
添加标签复选框。但当我检查更改事件的复选框没有被提升时
function testing(id) {
$('.todo-card').prepend('<div class="todo-task"> ' +
'<input type="checkbox" id="'+id+'"/> '+
'<label for="'+id+'">'+$("#todoadd").val()+' <span class="todo-remove mdi-action-delete"></span> '+
'</label> </div> ');
}
<script>
$(document).ready(function () {
});
$("input[type=checkbox]").change(function () {
alert("asdasdada");
});
<script>
答案 0 :(得分:0)
使用委托方法指定事件,而不是直接:
$(document).ready(function() {
$("input[type=checkbox]").on('change', function() {
alert($(this).prop('checked'));
});
});
通过此模式,当您添加新行时,将再次执行该事件。