Answer the question
In order to leave comments, you need to log in
Clicking on a class doesn't work?
$(".user-row-id").click(function(e) {
e.preventDefault();
var link = $(this);
uid = link.attr("data-user-id");
$.ajax({
type: "GET",
url: "getOtpInfo.php",
data: {"userId": uid},
cache: false,
success: function(response){
var data = JSON.parse(response);
console.log(data);
$('.vacation-row').remove();
for(var i=0;i<data.length;i++) {
let tr = $('<tr class="vacation-row">'
+'<td align="center">'
+'<a href="' + data[i]['ID_Vacation'] + '" data-vacation_redaction-id="' + data[i]['ID_Vacation'] + '" id="polojit" class="btn btn-default data-vacation_redaction-id" data-toggle="modal" data-target="#redaction_vacation"><em class="fa fa-pencil"></em></a>'
+'<a data-vacation-id="' + data[i]['ID_Vacation'] + '" class="btn btn-danger data-vacation-id" data-toggle="modal" data-target="#dell_vacation"><em class="fa fa-trash"></em></a>'
+'</td>'
+'<td>' + data[i]['Start_date'] + '</td>'
+'<td>' + data[i]['End_date'] + '</td>'
+'<td>' + data[i]['Day_numb'] + '</td>'
+'<td>' + data[i]['Unspoken_days'] + '</td>'
+'<td>' + data[i]['Main'] + '</td>'
+'<td>' + data[i]['Secondary'] + '</td>'
+'<td>' + data[i]['Number_decree'] + '</td>'
+'<td>' + data[i]['Date_decree'] + '</td>'
+'</tr>');
tr.appendTo('#table-content');
}
}
});
});
<td>
$(".data-vacation_redaction-id").click(function(e){
e.preventDefault();
alert("Проверка");
});
Answer the question
In order to leave comments, you need to log in
The click binds to existing elements, and these are added later, so no handler is attached to them. Need to write like this
$("#table-content").on("click", ".data-vacation_redaction-id", function () {
e.preventDefault();
alert("Проверка");
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question