有人可以帮助我,我想在更改后获取输入值,或者在更改日期输入值后弹出警报警告标志。所以这是我的代码
// Formatting function for row details - modify as you need
function format(d) {
var html =
'<td>' +
'<input type="date" name="s_date" class="" id="_s_date" data-type="date" data-role="datepicker"></input>' +
'<input type="submit" id="_submit" ></input>' +
'</td>' +
'</tr>' +
'</table>' +
'</form>';
// `d` is the original data object for the row
return (
html
);
}
$('tbody').on('click', 'td', function(e) {
var tr = $(this).closest('tr');
id = $(this).closest('table').attr('id');
table = $('#' + id).DataTable();
var row = table.row(tr);
if (row.child.isShown()) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
} else {
// Open this row
row.child(format(row.data(), id)).show();
tr.addClass('shown');
}
});
$('#_s_date').on('change', 'button[role="button"]', function(e) {
alert('you change the date');
});
有人可以帮我解决这个问题吗
我尝试过使用
$('#_s_date').on('change', function(){
alert("you are changing the date);
});
但它不起作用。
调用函数格式后,我认为你应该回忆一下jquery主动代码块:$(function(){}),并将代码绑定事件放入其中,因为当你以函数格式创建新元素时,html dom树已经改变,绑定在 jquery 无法再次找到的元素上的事件处理程序可能不起作用,