HTML;
<div class="col-lg-9" style="background-color:#ffffff; z-index:-1;">
<h2 id="titleH2"></h2>
<div class="table-responsive">
<table class="table table-striped" id="tableId">
<thead>
<tr>
<th>#</th>
<th>Word</th>
<th>Meaning</th>
<th>Type</th>
</tr>
</thead>
<tbody id="tbodyId">
</tbody>
</table>
</div>
</div>
javascript; (Data is displayed when the page is loaded.)
window.onload = function(){
showAllWords();
}
function showAllWords(){
$.ajax({
url: "${pageContext.request.contextPath}/myWords/allWords",
type: "GET",
async:false,
success: function(data) {
$('#tbodyId').empty();
var trHTML = '';
var index = 1;
$.each(data, function() {
trHTML += "<tr>";
$.each(this, function(k, v) {
if(k == "idWord"){
trHTML += "<td>" + index + "</td>";
index++;
}
else{
trHTML += "<td>" + v + "</td>";
}
});
trHTML += "<td>";
trHTML += "<input type=\"submit\" class=\"btn btn-primary\" value=\"Delete\">";
trHTML += "</td>";
});
$('#tbodyId').append(trHTML);
}
});
}
Output:
I can't click 'Delete buttons' after append HTML. So, buttons are not clickable. How can I fix this problem or what should I change?
